-
multithreading
Hi, done a search on multithreading and became a bit wiser, but not as wise as I was hoping for ;)
In this program I'm writing I've got 2 "almost" infinite loops (until I say STOP that is) that need to be run all the time. It's socket testing ...
So the first thread contains a server listening process. I'm trying to get a multi-user server ready. Therefor I need to constantly "listen" -> thread must be kept alive
Once a client is connected, the first loop creates a new thread. This thread is the socket receive code. This is also an "infinite" loop (until a certain command) because a client can type anything at any moment.
The second thread is being executed but seems to stop almost immediately to continue on running the first thread...
Now, I was thinking ... isn't there a way to switch threads every now and then...
so :
--- thread 1
--- thread 2
--- thread 1
--- thread 2
....
Any ideas and solutions are welcome !
Vamp
-
look at the threading class. you can spawn separate threads and you can use Delegates to interact between them. I think the Namespace is System.Threading
-
yeah, that's what I'm doing at the moment
ThrServer = new threading.thread(addressof me.startServer)
ThrServer.start()
and also a ThrReceive.
But it seems that the focus is always goes back to ThrServer in stead of constantly switching between the 2 threads ...