Created
January 25, 2015 05:20
-
-
Save scionwest/f4c4913047a09c7d6c22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var buffer = new byte[1024]; | |
| this.networkStream.BeginRead( | |
| buffer, | |
| 0, | |
| 1024, | |
| new AsyncCallback(ReceivedMessage), | |
| buffer); | |
| private void ReceivedMessage(IAsyncResult ar) | |
| { | |
| var buffer = ar.AsyncState as byte[]; | |
| int bytesReceived = this.networkStream.EndRead(ar); | |
| ar.AsyncWaitHandle.WaitOne(); | |
| if (bytesReceived == 0) | |
| { | |
| return; | |
| } | |
| string result = System.Text.Encoding.Default.GetString(buffer); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment