Bryan Martin <(E-Mail Removed)> wrote:
> Define a public variabl mbol_Shutdown. Next when you are ready to shut the
> socket down, assign the global mbol_Shutdown variable to True and signal the
> System.Threading.ManualResetEvent "mobj_ListenResetEvent"
> (mobj_ListenResetEvent.Set()). This should allow you to break out of the
> loop.
>
> While True
> mobj_ListenResetEvent.Reset()
> mobj_Socket.BeginAccept(New AsyncCallback(AddressOf
> AcceptCallback), mobj_Socket)
> mobj_ListenResetEvent.WaitOne()
> If mbol_Shutdown then Exit While
> End While
>
> 'clean up
Slightly cleaner would be to make the while construct *itself* test the
flag. However, you should also synchronize access to the flag to make
sure you don't just get a cached version each iteration. You could do
that by making the flag volatile, or by setting/reading a property
which contains a lock.
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too