Hi Lorens,
This is not a very good idea. It is much more performant to have a dedicated
reader which dispatches the messages into queues (one per worker thread).
Furthermore the receiving lidgren thread raise san event once there are new
messages available so your dedicated reader has virtually no impact on
CPU/thread starvation.
You can do this with something lite this:
AutoResetEvent waitDataSignal = netSvr.MessageReceivedEvent;
do{
if ((receivedMsg = netSvr.ReadMessage()) != null)
{
switch (receivedMsg.MessageType)
{
// ... DO WHATEVER YOU DO
}
}
else
waitDataSignal.WaitOne(150); // some timeout so that after 150 ms
we can check the end condition and terminate
} while (isMyServerRunning);
HTH
Riki
Hi all
LLORENS
--
You received this message because you are subscribed to the Google Groups
"lidgren-network" group.
To post to this group, send email to lidgren...@googlegroups.com.
To unsubscribe from this group, send email to
lidgren-netwo...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/lidgren-network?hl=en.
_____
<< ella for Spam Control >> has removed 335 Spam messages and set aside 122
Newsletters for me
You can use it too - and it's FREE! www.ellaforspam.com