Bump external/ikdasm to master.
[mono-project.git] / mono / tests / async_read.cs
blobbde780228512149d8121477f9b334537247aef30
1 using System;
2 using System.IO;
3 using System.Threading;
5 class Test {
7 static int sum = 0;
9 static void async_callback (IAsyncResult ar)
11 byte [] buf = (byte [])ar.AsyncState;
12 sum += buf [0];
15 static int Main () {
16 byte [] buf = new byte [1];
17 AsyncCallback ac = new AsyncCallback (async_callback);
18 IAsyncResult ar;
19 int sum0 = 0;
21 FileStream s = new FileStream ("async_read.exe", FileMode.Open, FileAccess.Read);
23 s.Position = 0;
24 sum0 = 0;
25 while (s.Read (buf, 0, 1) == 1)
26 sum0 += buf [0];
28 s.Position = 0;
30 do {
31 ar = s.BeginRead (buf, 0, 1, ac, buf);
32 } while (s.EndRead (ar) == 1);
33 sum -= buf [0];
35 Thread.Sleep (100);
37 s.Close ();
39 Console.WriteLine ("CSUM: " + sum + " " + sum0);
40 if (sum != sum0)
41 return 1;
43 return 0;