473,508 Members | 2,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling An Asynchronous Web Service from UI Thread

Hi There

This question is about calling an asynchronous web service from the UI
thread. Unless I am making a fundamental error, it appears that the
asynchronous web service call seems to spark off an
Application.DoEvents() when system resources are low and the message
loop has queued requests.

Here are some snippets of code to describe the problem:

The form has a datagrid, which usually contains 1000 or so records. In
the datagrids current cell changed event handler we have:

AsyncCallback myCallBack = new AsyncCallback(WebServiceCallback);
Debug.WriteLine("About to make web service call");
STE.WebClient.JobClient.Client.BeginGetBooking(thi s.ID,myCallBack,new
Object());
Debug.WriteLine("REACHED LINE AFTER WEB SERVICE CALL");

The call back method 'WebServiceCallback' just updates a text box:

public void WebServiceCallback (IAsyncResult ar)
{
if (InvokeRequired)
{
// We're not in the UI thread, so we need to call BeginInvoke
BeginInvoke(new MySpecialDelegate(WebServiceCallback,new object[
{ar});
}
else
{
this.booking = STE.WebClient.JobClient.Client.EndGetBooking(ar);
accountTextBox.Text = this.booking.Status;
}
}

If the user holds down the down arrow key then he/she can scroll down
the datagrid very quickly, resulting in quickfire calls to the web
service. I would expect to see a pattern of debug.write lines where
"About to make web service call" is followed by a corresponding
"REACHED LINE AFTER WEB SERVICE CALL".

The above behavour occurs most of the time. However if I open several
other applications (such as Access, Excel ... ) then repeat the above
experiment, by holding down the arrow key and quickly scrolling down
the datagrid, the "About to make web service call" write lines start to
appear after each other, with no corresponding "REACHED LINE AFTER WEB
SERVICE CALL" messages. After a few hundred of the "About to make web
service call" messages appear the program crashes with "An unhandled
exception of type 'System.StackOverflowException' occurred in
system.windows.forms.dll"

The only way I can see this happening is if the internals of
BeginGetBooking have some kind of Application.DoEvents() call ?

Please Help!

Bill

Nov 17 '05 #1
0 1545

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
368
by: Marina | last post by:
Hi, we have an app, that executes jobs submitted from an outside application. It executes them asynchronusly, by creating a delegate to the method that can run the job, and calling BeginInvoke on...
3
5107
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
4
5416
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
4
2316
by: jim | last post by:
Hi All, I try to make an asynchronous call to a web service method as below under MS visual .NET studio 2003: WebService webSrv = new WebService(); AsyncCallback cb = new...
0
1026
by: Dave | last post by:
If I'm making several asynchronous web service calls using the services Begin/End methods. How do you return the results of the webservice back to the main thread or calling page? Here's my...
4
4781
by: Edwin Gomez | last post by:
I'm a C# developer and I'm new to Python. I would like to know if the concept of Asynchronous call-backs exists in Python. Basically what I mean is that I dispatch a thread and when the thread...
4
4067
by: Morgan Cheng | last post by:
Since ASP.NET 2.0, asynchronous web service client can be implemented with event-based pattern, instead of original BeginXXX/EndXXX pattern. However, I didn't find any material about event-based...
3
1340
by: John Skandar | last post by:
I've found a free WebService on the net for a currency converter and have created a class to use it with the WSDL tool. I call the WebService method asynchronously: ...
0
1240
by: =?Utf-8?B?aWFtc2Rr?= | last post by:
I have a windows client that calls web service 1 (Broker) synchronously, web service 1 then calls web service 2 (Service) asynchronously, web service 2 sleeps its thread for 10 seconds. When I put...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.