Asynchronous Question
-
Hi all, Some background information: I have a method A that calls another method B. In method B an asynchronous TCP/IP read occurs:
this.tcpClient.GetStream().BeginRead(byteReadBuffer, 0, byteReadBuffer.Length, new AsyncCallback(ProcessReadBuffer), tcpClient.GetStream());
on result methodProcessReadBuffer
So my question: How can I wait for the asynchronousProcessReadBuffer
method to complete in method B. Reason being that I require some results fromProcessReadBuffer
method in method A? Many thanks in advance. Kind regards,The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Hi all, Some background information: I have a method A that calls another method B. In method B an asynchronous TCP/IP read occurs:
this.tcpClient.GetStream().BeginRead(byteReadBuffer, 0, byteReadBuffer.Length, new AsyncCallback(ProcessReadBuffer), tcpClient.GetStream());
on result methodProcessReadBuffer
So my question: How can I wait for the asynchronousProcessReadBuffer
method to complete in method B. Reason being that I require some results fromProcessReadBuffer
method in method A? Many thanks in advance. Kind regards,The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
Why not just call it synchronously then?
Regards, Rob Philpott.
-
Why not just call it synchronously then?
Regards, Rob Philpott.
Good point ... :sigh: That's that I did at the end of the day, but was curious how to make it happen :confused:
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Hi all, Some background information: I have a method A that calls another method B. In method B an asynchronous TCP/IP read occurs:
this.tcpClient.GetStream().BeginRead(byteReadBuffer, 0, byteReadBuffer.Length, new AsyncCallback(ProcessReadBuffer), tcpClient.GetStream());
on result methodProcessReadBuffer
So my question: How can I wait for the asynchronousProcessReadBuffer
method to complete in method B. Reason being that I require some results fromProcessReadBuffer
method in method A? Many thanks in advance. Kind regards,The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Try storing the result in an IAsyncResult variable and then call AsyncWaitHandle.WaitOne() on that object.
Hi, Thanks for the response. I did try doing that, but I noticed that the WaitOne() returns immediately with a true result and only then after it goes into the method. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
-
Hi all, Some background information: I have a method A that calls another method B. In method B an asynchronous TCP/IP read occurs:
this.tcpClient.GetStream().BeginRead(byteReadBuffer, 0, byteReadBuffer.Length, new AsyncCallback(ProcessReadBuffer), tcpClient.GetStream());
on result methodProcessReadBuffer
So my question: How can I wait for the asynchronousProcessReadBuffer
method to complete in method B. Reason being that I require some results fromProcessReadBuffer
method in method A? Many thanks in advance. Kind regards,The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^
Hi, BeginRead does not have to specify a callback method and you then call EndRead when the result of the async operation is required. EndRead will block until the result is available. http://msdn.microsoft.com/en-us/library/ms228967.aspx[^] Alan.
-
Hi, Thanks for the response. I did try doing that, but I noticed that the WaitOne() returns immediately with a true result and only then after it goes into the method. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:java: Programm3r My Blog: ^_^