public RepeatedMethodCaller(int nrOfCalls, TimeSpan delay, PerformCallDelegate callPerformer, TestService serviceToUse) { m_delay = delay; m_nrOfCalls = nrOfCalls; m_callPerformer = callPerformer; m_serviceToUse = serviceToUse; }
private void RunMultithreaded(PerformCallDelegate remoteMethodCaller, int nrOfCalls, int nrOfThreads) { ArrayList methodRunners = new ArrayList(); ArrayList threads = new ArrayList(); for (int i = 0; i < nrOfThreads; i++) { TimeSpan delay = TimeSpan.FromMilliseconds(m_random.Next(7)); RepeatedMethodCaller rmc1 = new RepeatedMethodCaller(nrOfCalls, delay, remoteMethodCaller, m_testService1); methodRunners.Add(rmc1); Thread sv1 = new Thread(new ThreadStart(rmc1.PerformCalls)); threads.Add(sv1); sv1.Start(); delay = TimeSpan.FromMilliseconds(m_random.Next(3)); RepeatedMethodCaller rmc2 = new RepeatedMethodCaller(nrOfCalls, delay, remoteMethodCaller, m_testService2); methodRunners.Add(rmc2); Thread sv2 = new Thread(new ThreadStart(rmc2.PerformCalls)); threads.Add(sv2); sv2.Start(); } foreach (Thread t in threads) { t.Join(); // wait for thread to finish } StringBuilder exceptionMsg = new StringBuilder(); bool foundEx = false; foreach (RepeatedMethodCaller rmc in methodRunners) { Exception[] exceptions = rmc.ExceptionsEncountered; if (exceptions.Length > 0) { foundEx = true; foreach (Exception ex in exceptions) { exceptionMsg.Append(ex.ToString() + "\n"); } } } if (foundEx) { throw new TestFailedException("the following exceptions were encountered while running the test:\n" + exceptionMsg.ToString()); } }
private void RunMultithreaded(PerformCallDelegate remoteMethodCaller, int nrOfCalls, int nrOfThreads) { ArrayList methodRunners = new ArrayList(); ArrayList threads = new ArrayList(); for (int i = 0; i < nrOfThreads; i++) { TimeSpan delay = TimeSpan.FromMilliseconds(m_random.Next(6)); RepeatedMethodCaller rmc1 = new RepeatedMethodCaller(nrOfCalls, delay, remoteMethodCaller, m_testService1); methodRunners.Add(rmc1); Thread sv1 = new Thread(new ThreadStart(rmc1.PerformCalls)); threads.Add(sv1); sv1.Start(); delay = TimeSpan.FromMilliseconds(m_random.Next(3)); RepeatedMethodCaller rmc2 = new RepeatedMethodCaller(nrOfCalls, delay, remoteMethodCaller, m_testService2); methodRunners.Add(rmc2); Thread sv2 = new Thread(new ThreadStart(rmc2.PerformCalls)); threads.Add(sv2); sv2.Start(); } foreach (Thread t in threads) { t.Join(); // wait for thread to finish } StringBuilder exceptionMsg = new StringBuilder(); bool foundEx = false; foreach (RepeatedMethodCaller rmc in methodRunners) { Exception[] exceptions = rmc.ExceptionsEncountered; if (exceptions.Length > 0) { foundEx = true; foreach (Exception ex in exceptions) { exceptionMsg.Append(ex.ToString() + "\n"); } } } if (foundEx) { throw new TestFailedException("the following exceptions were encountered while running the test:\n" + exceptionMsg.ToString()); } }
public STAThreadCaller(Control ctl) { this.ctl = ctl; performCallDelegate = new PerformCallDelegate(DoPerformCall); }
public STAThreadCaller(Control ctl) { this.ctl = ctl; performCallDelegate = new PerformCallDelegate(DoPerformCall); }
public RepeatedMethodCaller(int nrOfCalls, TimeSpan delay, PerformCallDelegate callPerformer, TestService serviceToUse) { m_delay = delay; m_nrOfCalls = nrOfCalls; m_callPerformer = callPerformer; m_serviceToUse = serviceToUse; }
private void RunMultithreaded(PerformCallDelegate remoteMethodCaller) { RunMultithreaded(remoteMethodCaller, 150, 35); // on the server side max 20 threads for multiplexed con. RunMultithreaded(remoteMethodCaller, 250, 4); // on the server side max 20 threads for multiplexed con. }
private void RunMultithreaded(PerformCallDelegate remoteMethodCaller) { RunMultithreaded(remoteMethodCaller, 150, 35); // on the server side max 20 threads for multiplexed con. RunMultithreaded(remoteMethodCaller, 250, 4); // on the server side max 20 threads for multiplexed con. }