T
Tony Johansson
Hi!
Here I have a simple program that is using asynchronous programming.
As you know there are three styles of programming with Asynchronous
Programming Model(APM) to deal with handling the end of the call in an
asynchronous call: wait-until-done, polling and callback.
In this example I use the Rendezvous model Wait-Unit-Done Model.
When using this model(wait-unitl.done) I can't find point to use this when I
still must wait being blocked until the asynchronous call is complete.
So you are blocked until complete when using wait-until-done and you are
blocked if you use the traditional synchronous model to read a file.
Does someone agree with me in this matter ?
static void Main()
{
byte[] buffer = new byte[1000];
string filename = "test.txt";
FileStream fstrm = new FileStream(filename, FileMode.Open,
FileAccess.Read,
FileShare.Read, 1024, FileOptions.Asynchronous);
IAsyncResult result = fstrm.BeginRead(buffer, 0, buffer.Length, null,
null);
int numBytes = fstrm.EndRead(result);
fstrm.Close();
}
//Tony
Here I have a simple program that is using asynchronous programming.
As you know there are three styles of programming with Asynchronous
Programming Model(APM) to deal with handling the end of the call in an
asynchronous call: wait-until-done, polling and callback.
In this example I use the Rendezvous model Wait-Unit-Done Model.
When using this model(wait-unitl.done) I can't find point to use this when I
still must wait being blocked until the asynchronous call is complete.
So you are blocked until complete when using wait-until-done and you are
blocked if you use the traditional synchronous model to read a file.
Does someone agree with me in this matter ?
static void Main()
{
byte[] buffer = new byte[1000];
string filename = "test.txt";
FileStream fstrm = new FileStream(filename, FileMode.Open,
FileAccess.Read,
FileShare.Read, 1024, FileOptions.Asynchronous);
IAsyncResult result = fstrm.BeginRead(buffer, 0, buffer.Length, null,
null);
int numBytes = fstrm.EndRead(result);
fstrm.Close();
}
//Tony