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 / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Canceling Asyncronous Calls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Nentidis - 09 Mar 2006 16:21 GMT
Hi there all,

I am starting an asyncronous call to a method passing
a callback delegate.
(More specifically a BeginRead in a network stream).
But there are times that I wish to cancel the asynchronous call
before it finishes, before the delegate is called.
How can I do that? Any ideas?

Thank you all in advance...

George
Vadym Stetsyak - 09 Mar 2006 17:48 GMT
Hello, George!

GN> I am starting an asyncronous call to a method passing
GN> a callback delegate.
GN> (More specifically a BeginRead in a network stream).
GN> But there are times that I wish to cancel the asynchronous call
GN> before it finishes, before the delegate is called.
GN> How can I do that? Any ideas?

AFAIK you can cancel it when you're in the callback method, just do not call EndRead...

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Mehdi - 09 Mar 2006 18:21 GMT
> Hello, George!
>
[quoted text clipped - 6 lines]
>
> AFAIK you can cancel it when you're in the callback method, just do not call EndRead...

When the callback method in invoked, the call has already been completed,
it's too late. Not calling EndRead will simply create a memory leak. You
MUST call EndXXX for every BeginXXX that you've called or you'll end up
with memory (and possibly other ressources as well) leaks. The only
exception to this rule is the Control.BeginInvoke() method which doesn't
require you to call the corresponding Control.EndInvoke() method. As for
the OP question, i'm afraid that unless the class that you are using
provides an explicit way to cancel an asynchronous operation, there is
nothing that you can do apart from ignoring the results in your callback
function.

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.