I am building a simple wpf application. The gui has a button, that when pressed will
create a background thread. A websocket server will run on this background thread. The
websocket server is event driven. There may be periods of low activity on this server,
but I don’t want the thread to terminate due to low volume. Is there a simple way to make
this thread persistent (at least until the app terminates)?
I am building a simple wpf application. The gui has a button, that when
Share
Why would the thread terminate due to low volume? The thread will only terminate when you tell it to. Even if your application and form are closed the background thread will most likely still run.
I have something similar with a TCPServer class (which uses a TCPListener) in a thread, and since the background thread can be blocked in a AcceptTcpClient() (which is blocking and in an infinite loop), the TCPListener has to be closed manually: