473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How can I abort asynchronous web service ?

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_function1Complet ed);

object userState;

ws.function1(userState);

Thread.Sleep(10000);

ws.CancelAsync (userState);

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

Thank you
Thanapol R.
Mar 9 '06 #1
2 4830
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/

Mar 9 '06 #2
"Thanapol R." <Th*******@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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,

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

MCT
MCSD.NET Early Achiever
Mar 12 '06 #3

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

Similar topics

11
by: Keith Langer | last post by:
I have an application which consists of a main work thread and multiple threads which each maintain a TCP socket. When a configuration change occurs, all activity on the socket threads must be...
2
by: Drew Stoddard | last post by:
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...
0
by: orekinbck | last post by:
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...
18
by: Urs Vogel | last post by:
Hi I wrote an application server (a remoting sinlgeton), where processes must be stopped in very rare cases, done thru a Thread.Abort(). Occasionally, and only after a Thread.Abort(), this...
6
by: Sakharam Phapale | last post by:
Private myThread As Thread Sub cmdStart_Click() myThread = New Thread(AddressOf PlayAudio) myThread.Start End Sub Sub PlayAudio() Open wave file Play wave file
1
by: Alexander Kaplunov | last post by:
I have two different scenarios: 1. I have an application that calls a web service and passes an object. Web Service takes that object and does some stuff with it, which could take...
0
by: Ken T. | last post by:
I have questions regarding what happens on the web server side during an asynchronous web method call when the client aborts its request via .Abort() call. Background: My client app...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
7
by: Marc Bartsch | last post by:
Hi, I have a background worker in my C# app that makes a synchronous HttpWebRequest.GetResponse() call. The idea is to POST a file to a server on the internet. When I call HttpWebRequest.Abort()...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...

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.