Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2006

Tip: Looking for answers? Try searching our database.

How can I abort asynchronous web service ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thanapol R. - 09 Mar 2006 03:43 GMT
I use .NET framework 2.0, and I want to cancel async. web service.
I tried to use "CancelAsync (object userstate)", but the web service is
still running.

This is my example code.
----------------------------------------------
MyService ws = new MyService();

ws.function1Completed += new
function1CompletedEnvetHandler(ws_function1Completed);

object userState;

ws.function1(userState);

Thread.Sleep(10000);

ws.CancelAsync (userState);

-------------------------------------

Thank you
Thanapol R.
Josh Twist - 09 Mar 2006 10:42 GMT
Because of the stateless nature of HTTP - this is very difficult to
achieve. The CancelAsync method will only cancel the local thread that
is making the request. The web service itself has no idea this has
happened.

Josh
http://www.thejoyofcode.com/
Martin Kulov - 12 Mar 2006 23:57 GMT
>I use .NET framework 2.0, and I want to cancel async. web service.
> I tried to use "CancelAsync (object userstate)", but the web service is
> still running.

Hi Thanapol,

initialize your web service call with an instance of Monitor class and check
its state during your asynchronous call. When it is signaled, just return
from the call. This is the most convenient way IMHO.

Regards,

Signature

Martin Kulov
http://www.codeattest.com/blogs/martin

MCT
MCSD.NET Early Achiever


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.