471,594 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

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 5394
"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
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.

Similar topics

1 post views Thread by DM | last post: by
8 posts views Thread by MuZZy | last post: by
1 post views Thread by Chris Morse | last post: by
2 posts views Thread by Ken | last post: by
3 posts views Thread by Terry Olsen | last post: by
reply views Thread by Frederic Hoornaert | last post: by
1 post views Thread by APA | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

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.