An example of an asynchronous client socket from MSDN

Question about this example: Asynchronous client socket . It says that the operations are asynchronous and they are ARE (beginxxx / endxxx are presented), but they use ManualResetEvent, and if I understand the sample code correctly, these calls:

  Receive(client);
  receiveDone.WaitOne();

The thread from which they were called will be blocked. So if I have an application with a UI and I call this asynchronous socket code from the main thread, the application will freeze ... Or am I mistaken? Unfortunately, I expected to send / receive some tcp commands asynchronously without freezing the main thread. Do I have to call all socket operations from this sample to avoid freezing?

+3
source share
2

, , . Beginxxx Endxxx, , () .

, blocker.WaitOne();. - , callback- beginconnect , ..

TPL ContinueWith . :)

+2

. MSDN , . . , , . .

: #

+1

All Articles