3 using System
.Collections
.Generic
;
4 using System
.Diagnostics
;
5 using System
.Threading
;
6 using System
.Threading
.Tasks
;
10 static IEnumerable
<int> UntilTimeout (uint ms
)
12 DateTime start
= DateTime
.UtcNow
;
13 for (int i
= 0; (DateTime
.UtcNow
- start
).TotalMilliseconds
< ms
; i
++)
17 public static void Main ()
19 object count_lock
= new object ();
22 ParallelOptions options
= new ParallelOptions
{
23 MaxDegreeOfParallelism
= Environment
.ProcessorCount
* 4,
26 Thread t1
= new Thread (() => {
27 ProcessStartInfo psi
= new ProcessStartInfo () {
30 RedirectStandardOutput
= true,
31 UseShellExecute
= false
34 Parallel
.ForEach (UntilTimeout (15 * 1000), options
, _
=> {
35 using (Process p
= Process
.Start (psi
)) {
36 p
.BeginOutputReadLine ();
43 if (count
% (10) == 0)
45 if (count
% (10 * 50) == 0)
53 while (!t1
.Join (0)) {
55 using (Process p
= Process
.GetProcessById (1));
56 } catch (ArgumentException
) {