Cancel an asynchronous method call made to delegate using BeginInv

G

Guest

I would like to cancel a call to BeginInvoke of a delegate (i.e. kill the
thread the call was made on). This would be done when a timeout occures for
the waitone call to the WaitHandle object of the IAsyncResult interface
returned by the BeginInvoke.

I have tried using the Close method of the WaitHandle object to end the call.

While I'm asking, please explain (in more detail than the MSDN Library) what
the bool parameter of the waitOne method does.
 
R

Richard Blewett [DevelopMentor]

Unfortunately you want to do something that can't be done - you cannot cancel the async execution. The WaitHandle sinply lets to time out the wait and so you can stop waiting for the request to finish.

As far as the boolean parameter goes I think its along these lines:

Context bound objects support the concept of causality based synchronization (like COM+). In other words a single call chain (whether cross threads or not) can access a bunch of objects protected by this causality lock, a different call chain (line of execution) cannot while the first has ownership of the lock. I think this flag means that if set to true, the causality lock should be released if the wait times out.

Fundementally, its not going to help you cancel an async method.

The only way of doing this is to use your own thread which you can Interrupt, either as a dedicated thread or as part of a custom threadpool.

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<[email protected]>

I would like to cancel a call to BeginInvoke of a delegate (i.e. kill the
thread the call was made on). This would be done when a timeout occures for
the waitone call to the WaitHandle object of the IAsyncResult interface
returned by the BeginInvoke.

I have tried using the Close method of the WaitHandle object to end the call.

While I'm asking, please explain (in more detail than the MSDN Library) what
the bool parameter of the waitOne method does.
--
Jeffrey Kingsley
Xerox Inovation Group
Xerox Corporation

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 27/09/2004



[microsoft.public.dotnet.languages.csharp]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top