protected override void Execute() { if (++_jobCount < 5) { _proc2.RunJob(new RunJobInProcessor(_proc1, this)); } }
protected override void Execute() { if (_jobCount < _maxJobs) { ++_jobCount; _proc1.RunJob(new CrossRunJob(_proc2, _proc1)); } }
public void TestRunJob() { _jobCount = 0; AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { SleepJob job = new SleepJob(400); DateTime start = DateTime.Now; // sleep for 2 secodns in processor's thread processor.RunJob(job); processor.RunJob(job); if (start.AddSeconds(0.79) >= DateTime.Now) { throw new Exception("TestRunJob() failed."); } } }
[SetUp] public void SetUp() { _core = new TestCore(); _resourceAP = new AsyncProcessor(true); _core.SetResourceAP(_resourceAP); _storage = _core.ResourceStore; _storage = _storage; MyPalStorage.Storage.OwnerThread = _resourceAP.Thread; _manager = new ProtocolHandlerManager(); _core.SetProtocolHandlerManager(_manager); _plugin = new MockPlugin(); _resourceAP.RunJob(new MethodInvoker(RegisterResources)); }
public void TestNullHandleAfterFinish() { AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { SleepJob job = new SleepJob(0); processor.RunJob(job); if (job.NextWaitHandle != null) { throw new Exception("TestNullHandleAfterFinish() failed."); } } }
[Test] public void RegisterFromAnotherThread() { AsyncProcessor processor = new AsyncProcessor(true); using ( processor ) { RegisterProtocolHandler handler = new RegisterProtocolHandler(_manager, _plugin); processor.RunJob(handler); if (handler.Exception != null) { throw handler.Exception; } } }
public void TestRunReenteringGroup() { AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { const int total = 5; _jobCount = 0; GroupJob job = new GroupJob(total, 1); processor.RunJob(job); if (_jobCount != total + 3) { throw new Exception("TestRunReenteringGroup(): GroupJob( total, 1 ) failed. _jobCount = " + _jobCount); } _jobCount = 0; job = new GroupJob(total, 3); processor.RunJob(job); if (_jobCount != total + 3) { throw new Exception("TestRunReenteringGroup(): GroupJob( total, 3 ) failed. _jobCount = " + _jobCount); } _jobCount = 0; job = new GroupJob(total, 5); processor.RunJob(job); if (_jobCount != total + 3) { throw new Exception("TestRunReenteringGroup(): GroupJob( total, 5 ) failed. _jobCount = " + _jobCount); } _jobCount = 0; job = new GroupJob(total, 11); processor.RunJob(job); if (_jobCount != total + 3) { throw new Exception("TestRunReenteringGroup(): GroupJob( total, 11 ) failed. _jobCount = " + _jobCount); } } }
public void TestRunMultipleStepJob() { MultipleStepJob job = new MultipleStepJob(); AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { processor.RunJob(job); } if (job.counter != 5) { throw new Exception("TestRunMultipleStepJob(): multiple step async processing. " + job.counter); } }
public FullTextIndexer.QueryResult QueryList(string query) { FullTextIndexer.QueryResult qr; ThreadPriority priority = _textProcessor.ThreadPriority; _textProcessor.ThreadPriority = ThreadPriority.Normal; try { qr = (FullTextIndexer.QueryResult)_textProcessor.RunJob("Searching for " + query, new QueryRequest(_textIndexer.ProcessQuery), query, Interlocked.Increment(ref _dummyCounter)); } finally { _textProcessor.ThreadPriority = priority; } return(qr); }
public void TestRunNonUniqieJobs() { SleepJob job = new SleepJob(200); AsyncProcessor proc = new AsyncProcessor(); AsyncProcessor proc1 = new AsyncProcessor(); using ( proc ) { using ( proc1 ) { proc.QueueJob(JobPriority.Immediate, job); Thread.Sleep(50); proc1.QueueJob(new JobRunner(job, proc)); Thread.Sleep(50); proc.RunJob(job); // this should throw the exception } } }
public void TestRecurringRunEqualJobs() { _jobCount = 0; AsyncProcessor proc1 = new AsyncProcessor(); AsyncProcessor proc2 = new AsyncProcessor(); RecurringRunJob job = new RecurringRunJob(proc1, proc2); using ( proc2 ) { using ( proc1 ) { proc1.RunJob(job); } } if (_jobCount != 5) { throw new Exception("TestRecurringRunEqualJobs() failed. _jobCount = " + _jobCount); } }
public void TestCrossRunJob() { _jobCount = 0; CrossRunJob._maxJobs = AsyncProcessor._maxWaitableHandles * 2 - 2; AsyncProcessor proc1 = new AsyncProcessor(); AsyncProcessor proc2 = new AsyncProcessor(); CrossRunJob job = new CrossRunJob(proc1, proc2); using ( proc2 ) { using ( proc1 ) { proc2.RunJob(job); } } if (_jobCount != CrossRunJob._maxJobs) { throw new Exception("TestCrossRunJob() failed. _jobCount = " + _jobCount); } }
public void TestNonBlockingRun() { _jobCount = 0; AsyncProcessor proc1 = new AsyncProcessor(); AsyncProcessor proc2 = new AsyncProcessor(); using ( proc1 ) { using ( proc2 ) { proc1.QueueJob(JobPriority.Immediate, new NonBlockingRunJob(proc2)); proc1.RunJob(new SleepJob(0)); Thread.Sleep(100); if (_jobCount != 2) { throw new Exception("TestNonBlockingRun() failed. _jobCount = " + _jobCount); } } } }
public void TestRunReenteringEnumerator() { _jobCount = 0; AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { const int total = 5; EnumeratorJob job = new EnumeratorJob(total, 100); DateTime start = DateTime.Now; processor.RunJob(job); if (start.AddMilliseconds(total * 99) > DateTime.Now) { throw new Exception("TestRunReenteringEnumerator() finished too early. _jobCount = " + _jobCount); } if (_jobCount != total + 1) { throw new Exception("TestRunReenteringEnumerator() failed. _jobCount = " + _jobCount); } } }
protected override void Execute() { _proc.RunJob(_job); }
protected override void Execute() { _proc.RunJob(new NamedJob()); }
protected override void Execute() { _pairProc.RunJob(new SleepJob(1000)); }