Recommended

Multicore community

 

Articles

Intel.com

Microsoft.co.il

 

Community

Microsoft Forums

Intel's Forum

Intel's Multicore Community

 

Resources

http://msdn.com/concurrency

Intel Multicore

NVidia Multicore GPU

 

Downloads

.Net Parallel Extensions

Intel's TBB

WinModules   

 

Tools

AsyncOp Logger

Intel thread analysis

Intel VTune

 

Contact

Asaf Shelly

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

-->

 

 

 

 

 

 
2 / 2
 
 
 
 
 
 
 
    // /  This HTML file was produced by the ProjectPublisher WebService, By Asaf Shelly                   / //
   // /    WebService URL is: http://Services.AsyncOp.com/ProjectPublisher/ProjectPublisherWSvc.asmx      / //
  // /    Learn more and find the source code here: http://AsyncOp.com                                   / //


void User()
{
   ReadAsync("C:\\temp\\temp.txt", 1000);
}

void ReadAsync(string ___path___, int ___timeout___)
{
   FileStream fs = new FileStream(___path___, FileMode.OpenOrCreate);
   ManualResetEvent manualEvent = new ManualResetEvent(false);
   byte[] buffer = new byte[256];

   IAsyncResult asyncResult = fs.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(OnReadCompletion), manualEvent);
   manualEvent.WaitOne(___timeout___, false);
   if (asyncResult.IsCompleted)
   {
      int numberOfBytesRead = fs.EndRead(asyncResult);
   }
   else fs.Close();  // Abort

}

static void OnReadCompletion(IAsyncResult asyncResult)
{
   (asyncResult.AsyncState as ManualResetEvent).Set();
}