cancel BeginConnect

  • Thread starter Thread starter g18c
  • Start date Start date
G

g18c

Hi, is there anyway of canceling the BeginConnect operation on a
socket?

I would like my user to be able to hit a button to abort the connection
attempt - i notice the sockets class does not provide an explicit
cancel instruction. Is there any way i can do this? Ideally i dont want
to use threads as OnConnect events make nice easy code.

One idea i have is that i could use the asyncresult.state and keep a
flag in there indicating if this async operation has been 'aborted',
then in the OnConnect handler i can check this flag and abort if
necessary?

Would it be possible to initiate a BeginConnect and then close the form
before the callback has had a chance to run? It would be nice for the
any pending async operations to complete on a socket.cancel method :(

Any ideas much appreciated

TIA

Chris
 
I would like my user to be able to hit a button to abort the connection
attempt - i notice the sockets class does not provide an explicit
cancel instruction. Is there any way i can do this? Ideally i dont want
to use threads as OnConnect events make nice easy code.

Close the socket.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
 
Back
Top