using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace AsyncFile
{
   class Program
   {
      static bool fileDone = false;
      static FileStream fs = null;
      static void Main(string[] args)
      {
         fs = new FileStream("cytat.txt", FileMode.Open);
         byte[] fileBytes = new byte[fs.Length];
         fs.BeginRead(fileBytes, 0, (int)fs.Length, new AsyncCallback(ReadEnd), null);
         while (!fileDone)
         {
            Console.WriteLine("Czekam na zakończenie odczytu pliku...");
         }

         Console.ReadLine();

      }

      static void ReadEnd(IAsyncResult ar)
      {
         int bytesRead = fs.EndRead(ar);
         Console.WriteLine("Wczytano {0} bajtów.", bytesRead);
         fs.Close();
         fileDone = true;
      }
   }
}
