Network Loop Problem
I am using Visual C# 2005 Beta 2 to make a simple server with a tray icon. The server is in a data loop of mine receiving data from clients but during this time (which is the entire time the program is running) I can't access the tray icon. It appears and has a balloon but if I right click it nothing happens. But as soon as the loop stops the menu appears. How do I get around this problem without compromising my loop?
If your network loop is using blocking I/O, create a separate thread that contains your data loop. Your current program is probably blocking on listening for network traffic, which means Windows-messages are just waiting in the queue, doing nothing.
If you don't want to burn your hands on multithreading, look into functions like select. That way you can create a loop having the following concept:
If you don't want to burn your hands on multithreading, look into functions like select. That way you can create a loop having the following concept:
while( running ){ // Listen for Windows messages and handle them while( PeekMessage( ... ) ) { case WM_BLABLA: etc... } // See if there is network traffic and handle it NetworkMessage mess; while( NetworkTrafficMessage( &mess ) ) { handleMessage( mess ); }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement