Debian Codegraph @

external/rx/Rx/NET/Source/Tests.System.Reactive/TestBase.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Threading;
8
9 namespace ReactiveTests
10 {
11 #if SILVERLIGHT && !SILVERLIGHTM7
12 public class TestBase : Microsoft.Silverlight.Testing.SilverlightTest
13 {
14 public void RunAsync(Action<Waiter> a)
15 {
16 EnqueueCallback(() =>
17 {
18 var w = new Waiter(TestComplete);
19 a(w);
20 w.Wait();
21 });
22 }
23
24 public void CompleteAsync()
25 {
26 EnqueueTestComplete();
27 }
28 }
29
30 public class Waiter
31 {
32 private Action _complete;
33
34 public Waiter(Action complete)
35 {
36 _complete = complete;
37 }
38
39 public void Set()
40 {
41 _complete();
42 }
43
44 public void Wait()
45 {
46 }
47 }
48 #else
49 public class TestBase
50 {
51 public void RunAsync(Action<Waiter> a)
52 {
53 var w = new Waiter();
54 a(w);
55 w.Wait();
56 }
57 }
58
59 public class Waiter
60 {
61 private ManualResetEvent _evt = new ManualResetEvent(false);
62
63 public void Set()
64 {
65 _evt.Set();
66 }
67
68 public void Wait()
69 {
70 _evt.WaitOne();
71 }
72 }
73
74 [AttributeUsage(AttributeTargets.Method)]
75 public class AsynchronousAttribute : Attribute
76 {
77 }
78 #endif
79 }