示例#1
0
        private static void GetDelayedInt(AsyncProcessor proc, int dummy)
        {
            object result = proc.RunUniqueJob(_delayedIntDelegate);

            if (result == null)
            {
                throw new Exception("RunUniqueJob() returned null!");
            }
            if ((int)result != e)
            {
                throw new Exception("RunUniqueJob() returned invalid value!");
            }
            ++count;
        }
示例#2
0
文件: DebugActions.cs 项目: mo5h/omeo
        public void Execute(IActionContext context)
        {
            AsyncProcessor tiAP = null;

            AsyncProcessor[] pool = AsyncProcessor.GetAllPooledProcessors();
            foreach (AsyncProcessor ap in pool)
            {
                if (ap.ThreadName == "TextIndex AsyncProcessor")
                {
                    tiAP = ap;
                }
            }
            if (tiAP != null)
            {
                tiAP.RunUniqueJob(new MethodInvoker(DumpTrie));
            }
        }
示例#3
0
        public void TestRunUniqieJobs()
        {
            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.RunUniqueJob(job);   // this shouldn't throw an exception
                }
            }
        }
示例#4
0
        public void TestRunWithException()
        {
            _exceptionHandled = false;
            AsyncProcessor proc = new AsyncProcessor();

            using ( proc )
            {
                proc.ExceptionHandler = new AsyncExceptionHandler(ExceptionHandler);
                proc.QueueJob(new SleepJob(200));
                AsyncProcessor proc1 = new AsyncProcessor();
                AsyncProcessor proc2 = new AsyncProcessor();
                AsyncProcessor proc3 = new AsyncProcessor();
                AsyncProcessor proc4 = new AsyncProcessor();
                AsyncProcessor proc5 = new AsyncProcessor();
                proc1.QueueJob(new ExceptionJobRunner(proc));
                proc2.QueueJob(new ExceptionJobRunner(proc));
                proc3.QueueJob(new ExceptionJobRunner(proc));
                proc4.QueueJob(new ExceptionJobRunner(proc));
                proc5.QueueJob(new ExceptionJobRunner(proc));
                try
                {
                    proc.RunUniqueJob(new ExceptionJob());
                }
                catch (Exception e)
                {
                    e = Utils.GetMostInnerException(e);
                    if (!(e is StrangeJobException))
                    {
                        throw new Exception(e.Message);
                    }
                }
                proc1.Dispose();
                proc2.Dispose();
                proc3.Dispose();
                proc4.Dispose();
                proc5.Dispose();
            }
        }
示例#5
0
 protected override void Execute()
 {
     _proc.RunUniqueJob(new ExceptionJob());
 }