Process sleep when form loses focus
While writing a server application with a windows form for a GUI a problem appeared. When a form 开发者_如何学Pythonloses focus the process sleep, so any networking will not work unless the form is in focus the whole time. Is there any way of creating a dialog or window that will keep its process running continuously?
I call a function called cServer::GetInstance()->CheckEvents(); which checks the events of the connection to see if anything special is happening, problem is, this AND the general process of listening on a port halts when the form loses focus. Is there a fix or work around for this?
If you must use a win32 gui app, your networking code should be in an independent dedicated thread.
A better solution over all, would be to make your "server" a windows service and your GUI a client application to the server.
精彩评论