Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


.NET Thread refuses to abort

This topic is 5189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've got a thread started,
_listenthread = new Thread(new ThreadStart(WaitForConnection));
and that thread does this
_socket = _tcplistener.AcceptSocket();
_timeoutcount = 0;
_thread = new Thread(new ThreadStart(RunThread));
What's wrong is that no matter what I do, I can't make this thread stop. I called _listenthread.Abort(), _listenthread = null, Application.ExitThread() and tried just Application.Exit() But whatever I do, when I close my form the application keeps running. It only works if I comment out _socket = _tcplistener.AcceptSocket(); so I know it has to do with that. Anybody know how to abort this process correctly? EDIT: ok, I figured it out. All I had to do was set _listenthread.IsBackground = true; Sorry for the trouble. [edited by - Trashcann on April 3, 2004 2:39:13 AM]

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
IsBackground isn''t a good solution, there is a better way:

The thread cannot be aborted since it´s in an unmanaged call to winsock. Your main thread should close the socket instead. The listener thread will then get an exception in the accept call.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!