By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,678 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,678 IT Pros & Developers. It's quick & easy.

Async Web Service Abort Question

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"Drew Stoddard" <Dr**********@discussions.microsoft.com> wrote in message news:C1**********************************@microsof t.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

P: n/a
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**********@discussions.microsoft.com> wrote in message news:C1**********************************@microsof t.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 discussion thread is closed

Replies have been disabled for this discussion.