private static void TrySend(int numThreads, int numCount, int ratioDoubleAdd, UpdateDispatchViewModel updateDispatchView, DispatchService dispatchService) { // execute IExecutorService threadPool = Executors.NewFixedThreadPool(numThreads); var future = new Future <bool> [numThreads]; var callables = new DispatchCallable[numThreads]; var producer = new DispatchProducer(updateDispatchView); for (int i = 0; i < numThreads; i++) { callables[i] = new DispatchCallable(producer, i, numCount, ratioDoubleAdd, updateDispatchView, dispatchService); future[i] = threadPool.Submit(callables[i]); } threadPool.Shutdown(); threadPool.AwaitTermination(new TimeSpan(0, 0, 10)); for (int i = 0; i < numThreads; i++) { Assert.IsTrue(future[i].GetValueOrDefault()); } }
public DispatchCallable(DispatchProducer sharedProducer, int threadNum, int numActions, int ratioDoubleAdd, UpdateDispatchViewModel updateDispatchView, DispatchService dispatchService) { _sharedProducer = sharedProducer; _threadNum = threadNum; _numActions = numActions; _ratioDoubleAdd = ratioDoubleAdd; _updateDispatchView = updateDispatchView; _dispatchService = dispatchService; }
public DispatchProducer(UpdateDispatchViewModel dispatchProcessor) { this.dispatchProcessor = dispatchProcessor; }
public DispatchFuture(UpdateDispatchViewModel view, DispatchFuture earlier) { this.view = view; this.earlier = earlier; }