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 Parallel.ForEach (UntilTimeout (15 * 1000), options, _ => {
28 using (Process p = Process.Start ("cat", "/dev/null")) {
35 if (count % (10) == 0)
37 if (count % (10 * 50) == 0)
45 while (!t1.Join (0)) {
47 using (Process p = Process.GetProcessById (1));
48 } catch (ArgumentException) {