R
Rogier
Hello,
I'm Writing my own NZb download App, using Async Network Streams en
Callback delegates. The Problem is that if I Want tot Receive Large
chunks of data (for instance the LIST NEWSGROUPS Response). I do not get
the Data at once.
Here is a piece of my source code:
I call the NetworkStream.ReadBegin as follows:
(ReadCallBack is the Call Back delegate)
byte[] ReadBuffer = new byte[100000];
stream.BeginRead(ReadBuffer, 0,
ReadBuffer.Length,ReadCallback,ReadBuffer);
And here is the Callback function:
protected void Stream_Read(IAsyncResult result)
{
int BytesRead = 0;
System.Text.ASCIIEncoding encoding = new
System.Text.ASCIIEncoding();
try
{
BytesRead = stream.EndRead(result);
}
catch (Exception e)
{
}
richTextBox1.Text +=
encoding.GetString((byte[])result.AsyncState, 0, BytesRead);
}
To get the full Response I have tot call the BeginRead Methode multiple
times, Currently I have to do it manually because I cant find a way to
check programmaticaly whether to call it again. Does anyone have A
solution for this problem ?
Thanks
Rogier
I'm Writing my own NZb download App, using Async Network Streams en
Callback delegates. The Problem is that if I Want tot Receive Large
chunks of data (for instance the LIST NEWSGROUPS Response). I do not get
the Data at once.
Here is a piece of my source code:
I call the NetworkStream.ReadBegin as follows:
(ReadCallBack is the Call Back delegate)
byte[] ReadBuffer = new byte[100000];
stream.BeginRead(ReadBuffer, 0,
ReadBuffer.Length,ReadCallback,ReadBuffer);
And here is the Callback function:
protected void Stream_Read(IAsyncResult result)
{
int BytesRead = 0;
System.Text.ASCIIEncoding encoding = new
System.Text.ASCIIEncoding();
try
{
BytesRead = stream.EndRead(result);
}
catch (Exception e)
{
}
richTextBox1.Text +=
encoding.GetString((byte[])result.AsyncState, 0, BytesRead);
}
To get the full Response I have tot call the BeginRead Methode multiple
times, Currently I have to do it manually because I cant find a way to
check programmaticaly whether to call it again. Does anyone have A
solution for this problem ?
Thanks
Rogier