473,585 Members | 2,512 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Async Web Service Abort Question

We are working in C#/Winforms and are using asynchronous client-side web
service calls (the Begin... and End... methods supplied by the web reference
creation). Many of these calls are contained in Windows forms that the user
can close before the web service call has completed. This seems to be
working fine, but I wanted to check to see if anyone has experienced any
problem with this. Specifically this is what I need to know: Is it safe to
allow a Windows form which contains a non-static web-service callback method
to be closed before the web-service has completed and therefore before the
callback has been made?

If this is not safe, what is the recommended way to abort an asynchronous
web service call without preventing the user from closing the form?

Drew Stoddard
Nov 12 '05 #1
2 5547
"Drew Stoddard" <Dr**********@d iscussions.micr osoft.com> wrote in message news:C1******** *************** ***********@mic rosoft.com...
problem with this. Specifically this is what I need to know: Is it safe to
allow a Windows form which contains a non-static web-service callback method
to be closed before the web-service has completed and therefore before the
callback has been made?
IIRC, the web service's proxy will run as a background thread so it will
go away when the main thread terminates. If you open the Task Manager
(with Ctrl-Alt-Del) after closing the WinForm application, and the process
is gone, then you know the thread that was waiting for the web service's
response has gone away, too (if you still see the WinForm app's process
then you have a non-background Thread still running).
If this is not safe, what is the recommended way to abort an asynchronous
web service call without preventing the user from closing the form?


You can't recall a web service like you can do with governors from
California. Web services are more like an errant pigskin pass, inexper-
ienced quarterbacks wish they can take their throw back but it's too
late, some defensive back is already returning it downfield.

Even though the server may still send a response, nobody is listening
anymore, right?
Derek Harmon
Nov 12 '05 #2
Thanks Derek, this is helpful. But I still have one concern. I know that if
the main thread terminates that any in-progress web service calls will get
cleaned up correctly. But what if the main thread continues to run? Suppose
you have an application with a main screen and a button which causes a child
window to be created, and within the child form a web service call is made.
Now say that before the web service call completes the user closes the
window. Now assume that the same action occurs 5 times. The main thread
continues to run as the child forms are opened and closed, and one async web
service call is initiated from each child.

My concern is about what happens down at the web service level (on the
client side, I'm not concerned about the server here). When the Begin...
call is made control is transferred to a thread from the application
ThreadPool as I understand it. Once the web service call is complete the
worker thread will attempt to make a callback to a method that no longer
exists, because the form object instance that contained the method has been
deleted. Is the web service mechanism smart enough to clean up the abandoned
call correctly? In our application this could happen multiple times, so it's
important to know whether resources are being chewed up by these abandoned
calls.

Any ideas how serious this might be?

Drew Stoddard

"Derek Harmon" wrote:
"Drew Stoddard" <Dr**********@d iscussions.micr osoft.com> wrote in message news:C1******** *************** ***********@mic rosoft.com...
problem with this. Specifically this is what I need to know: Is it safe to
allow a Windows form which contains a non-static web-service callback method
to be closed before the web-service has completed and therefore before the
callback has been made?


IIRC, the web service's proxy will run as a background thread so it will
go away when the main thread terminates. If you open the Task Manager
(with Ctrl-Alt-Del) after closing the WinForm application, and the process
is gone, then you know the thread that was waiting for the web service's
response has gone away, too (if you still see the WinForm app's process
then you have a non-background Thread still running).
If this is not safe, what is the recommended way to abort an asynchronous
web service call without preventing the user from closing the form?


You can't recall a web service like you can do with governors from
California. Web services are more like an errant pigskin pass, inexper-
ienced quarterbacks wish they can take their throw back but it's too
late, some defensive back is already returning it downfield.

Even though the server may still send a response, nobody is listening
anymore, right?
Derek Harmon

Nov 12 '05 #3

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

Similar topics

1
10047
by: DM | last post by:
I want to be able to cancel an async call to a VB.Net web service and for the web service to know it has been cancelled so that it can abort gracefully. I have used the Begin.... and End... methods of the proxy class to successfully run the web service asynchronously. And I used the Abort() method of the IAsyncResult return by the Begin......
8
3509
by: MuZZy | last post by:
Hi, Could someone pls help me here: If i use async sockets in the separate thread like this: void ThreadFunction() { ..... 1. MySocket.BeginAccept(AsyncCallBack(OnConnectRequest), MySocket);
1
4461
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am assuming that this is not an uncommon piece of software. I want to get an architecture that conforms as closely as possible with the...
1
6273
by: Chris Morse | last post by:
WARNING: Verbosity: skip to the very bottom paragraph for succinct version of my question.) Hi- I can't seem to find an answer to this. I am playing around with a variation of the ".NET Framework Developer's Guide" (in the MSDN docs) "Using an Asynchronous Server Socket" sample. As usual with docs like this, the example isn't very...
2
2458
by: Ken | last post by:
I have an async Web service working inside a Try block just like MS says Try Dim cb As New AsyncCallback(AddressOf callbackWs) myWS.BeginUpdater("StringChain", cb, myWS) Catch x As Exception MessageBox.Show("Something happened") End Try the Callback routine
1
4314
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async method calling, but what if you are already in a worker thread in a Windows Forms application when doing the web service call. In this case there is no...
3
1623
by: Terry Olsen | last post by:
I'm trying to shutdown my service by stopping all the started classes & threads. In each Class I have a Public Sub like this: Public Sub StopIntf() Try Threading.Thread.CurrentThread.Abort() Catch End Try End Sub
0
1998
by: Frederic Hoornaert | last post by:
Hi, I have a webrequest which is started Asynchronously : _pf = new PrimeFactorizer(); _pf.FactorizeCompleted += new FactorizeCompletedEventHandler(pf_FactorizeCompleted); _pf.FactorizeAsync(factorizableNum);
1
2845
by: APA | last post by:
I've seen the MS sample async web request pattern and I ask is it really async if it is using a ManualResetEvent and setting WaitOne()? The ManualResetEvent object is being declared as a static variable so isn't it causing problems with other threads that may be using the same class to execute the async web request? If I remove the...
0
7904
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7835
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8195
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8334
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6596
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3831
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3856
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1444
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1171
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.