EncoderReplacementFallbackBuffer.Reset() did not really reset its internals.
[mono-project/dkf.git] / mcs / tests / test-async-23.cs
bloba198efb1054859617f5c61fa9f49ca4396f28f29
1 // Compiler options: -langversion:future
3 using System;
4 using System.Threading;
5 using System.Threading.Tasks;
7 class MyContext : SynchronizationContext
9 public int Started;
10 public int Completed;
11 public int PostCounter;
12 public int SendCounter;
14 public override void OperationStarted ()
16 ++Started;
17 base.OperationStarted ();
20 public override void OperationCompleted ()
22 ++Completed;
23 base.OperationCompleted ();
26 public override void Post (SendOrPostCallback d, object state)
28 ++PostCounter;
29 base.Post (d, state);
32 public override void Send (SendOrPostCallback d, object state)
34 ++SendCounter;
35 base.Send (d, state);
40 public class TestPostContext
42 static async Task<int> Test ()
44 return await Task.Factory.StartNew (() => 1);
47 public static int Main ()
49 var context = new MyContext ();
50 try {
51 SynchronizationContext.SetSynchronizationContext (context);
52 var t = Test ();
53 Task.WaitAll (t);
54 } finally {
55 SynchronizationContext.SetSynchronizationContext (null);
58 if (context.Started != 0 || context.Completed != 0 || context.SendCounter != 0)
59 return 1;
61 if (context.PostCounter != 1)
62 return 2;
64 Console.WriteLine ("ok");
65 return 0;