Example

 using System; using System.IO; using System.Text; using System.Threading; namespace Samples { public class AsyncCallBackSample { const int limit = 512; const int readlimit = 15; public class StateHolder { public byte[] bytes ; public FileStream fs ; } public static void Main() { string s = "filestream.txt"; FileStream fs = new FileStream(s, FileMode.Open, FileAccess.Read); StateHolder sh = new StateHolder(); sh.fs = fs; sh.bytes = new Byte[limit]; AsyncCallback ac = new AsyncCallback(CallMe); fs.BeginRead(sh.bytes, 0, readlimit, ac, sh); Thread.Sleep(2000); Console.WriteLine(); Console.WriteLine("Finishing Main()"); } public static void CallMe(IAsyncResult asyncResult) { StateHolder sh = (StateHolder) asyncResult.AsyncState; FileStream ...

Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.