Created
June 22, 2011 01:59
-
-
Save Azerothian/1039372 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
public override int Read(byte[] buffer, int offset, int count) | |
{ | |
lock (_incomingLock) | |
{ | |
_incomingMemoryStream.Position = 0; | |
var cnt = _incomingMemoryStream.Read(buffer, offset, count); | |
int amountleft = (int)(_incomingMemoryStream.Length - _incomingMemoryStream.Position); | |
var newMs = new MemoryStream(); | |
if (amountleft > 0) | |
{ | |
byte[] data = new byte[amountleft]; | |
_incomingMemoryStream.Read(data, 0, amountleft); | |
newMs.Write(data, 0, data.Length); | |
} | |
_incomingMemoryStream.Close(); | |
_incomingMemoryStream = newMs; | |
return cnt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment