PC Review


Reply
Thread Tools Rate Thread

How to cancel a pending BeginReceive ?

 
 
Lee Gillie
Guest
Posts: n/a
 
      5th May 2004
What is the proper way to cancel a pending BeginReceive/EndReceive ?
Can it be done without generating an exception ?

Currently I shutdown and close the socket. The blocking "EndReceive"
throws System.ObjectDisposedException.

I try to avoid throwing exceptions when ever possible, and reserve
them for unanticipated problems. Trying to stop a background
read/process loop is an anticipated activity. For me the debugger
delays 15 seconds when ever an exception is thrown. But regardless, I
am hoping for a cleaner approach. I can not find guidance on this
issue in framework documentation.

Forgive the cross posts. It would be nice to have a specific
framework/network related NG.

Thanks for any insight - Best regards - Lee Gillie - Spokane, WA


 
Reply With Quote
 
 
 
 
Lee Gillie
Guest
Posts: n/a
 
      5th May 2004
Ok, experimentation shows this seems to be the trick...

Do a shutdown on the socket.
EndReceive completes with zero bytes
I need to WAIT for this occur before shutdown thread then does a
close, otherwise the exception

"Lee Gillie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What is the proper way to cancel a pending BeginReceive/EndReceive ?
> Can it be done without generating an exception ?
>
> Currently I shutdown and close the socket. The blocking

"EndReceive"
> throws System.ObjectDisposedException.
>
> I try to avoid throwing exceptions when ever possible, and reserve
> them for unanticipated problems. Trying to stop a background
> read/process loop is an anticipated activity. For me the debugger
> delays 15 seconds when ever an exception is thrown. But regardless,

I
> am hoping for a cleaner approach. I can not find guidance on this
> issue in framework documentation.
>
> Forgive the cross posts. It would be nice to have a specific
> framework/network related NG.
>
> Thanks for any insight - Best regards - Lee Gillie - Spokane, WA
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I cancel pending server request? =?Utf-8?B?am9obm5jaGVyaWU=?= Microsoft Outlook Installation 0 6th Sep 2004 07:27 PM
How to cancel pending CHKDSK J Warren Microsoft Windows 2000 18 9th Jun 2004 02:45 AM
How to cancel a pending BeginReceive ? Lee Gillie Microsoft VB .NET 1 5th May 2004 08:31 PM
How to cancel a pending BeginReceive ? Lee Gillie Microsoft Dot NET Framework 1 5th May 2004 08:31 PM
Calling BeginReceive with receive pending ?lafur Helgi R?gnvaldsson Microsoft C# .NET 0 12th Dec 2003 05:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:44 AM.