public void ProcessAll(string uuid) { Task t = new Task(async () => { ProcessRequests msgs = new ProcessRequests(uuid); try { _lockToSend.WaitOne(); Helpers.Log("begin(ProcessAll)"); int res = await msgs.Execute(); Helpers.Log("end(ProcessAll): " + res); _lockToSend.Release(); } catch (Exception) { Helpers.Log("fail(ProcessAll)"); } }); t.Start(); }
public void TestProcessAll () { int n1 = 0, n2 = 0, n3 = 0, n4 = 0; int res = 0; Tuple<int, bool> t1 = GetCachedTest ("CCC", ""); n1 = t1.Item1; Tuple<int, bool> t2 = GetCachedTest ("LCC", ""); n2 = t2.Item1; Tuple<int, bool> t3 = GetCachedTest ("PCC", ""); n3 = t3.Item1; Tuple<int, bool> t4 = GetCachedTest ("ECC", ""); n4 = t4.Item1; string uuid = UUID.GetNew (); for (int i = n1; i < 20; i++) if (!String.IsNullOrEmpty (CacheTestCrash (uuid))) n1++; for (int i = n2; i < 20; i++) if (!String.IsNullOrEmpty (CacheTestHandledException (uuid))) n2++; for (int i = n3; i < 20; i++) if (!String.IsNullOrEmpty (CacheTestPing (uuid))) n3++; for (int i = n4; i < 20; i++) if (!String.IsNullOrEmpty (CacheTestEvent (uuid))) n4++; ProcessRequests proc = new ProcessRequests (uuid); Task.Run (async () => { res = await proc.Execute (); }).Wait (); Helpers.SleepFor (4000); Assert.AreEqual (27, res, "ProcessAll requests sent"); }