3 using System
.Diagnostics
;
5 using System
.Threading
;
6 using System
.Threading
.Tasks
;
12 Action
<Process
>[] tests
= new Action
<Process
> [] {
13 new Action
<Process
> (Test1
),
14 new Action
<Process
> (Test2
),
17 ProcessStartInfo psi
= new ProcessStartInfo () {
19 Arguments
= "../.. -maxdepth 3", // this test should be run from mono/tests, so that will list all files in the repo
20 UseShellExecute
= false,
21 RedirectStandardOutput
= true,
22 RedirectStandardError
= true,
25 foreach (Action
<Process
> test
in tests
) {
26 for (int i
= 0; i
< 200; ++i
) {
27 test (new Process () { StartInfo = psi }
);
32 static void Test1 (Process p
)
34 ManualResetEvent mre_exit
= new ManualResetEvent (false);
35 ManualResetEvent mre_output
= new ManualResetEvent (false);
36 ManualResetEvent mre_error
= new ManualResetEvent (false);
38 p
.EnableRaisingEvents
= true;
39 p
.Exited
+= (s
, a
) => mre_exit
.Set ();
43 p
.OutputDataReceived
+= (s
, a
) => {
50 p
.ErrorDataReceived
+= (s
, a
) => {
57 p
.BeginOutputReadLine ();
58 p
.BeginErrorReadLine ();
60 if (!mre_exit
.WaitOne (10000))
62 if (!mre_output
.WaitOne (1000))
64 if (!mre_error
.WaitOne (1000))
68 static void Test2 (Process p
)
70 ManualResetEvent mre_output
= new ManualResetEvent (false);
71 ManualResetEvent mre_error
= new ManualResetEvent (false);
75 p
.OutputDataReceived
+= (s
, a
) => {
82 p
.ErrorDataReceived
+= (s
, a
) => {
89 p
.BeginOutputReadLine ();
90 p
.BeginErrorReadLine ();
92 if (!p
.WaitForExit (10000))
94 if (!mre_output
.WaitOne (1000))
96 if (!mre_error
.WaitOne (1000))