/// <summary> /// All threads do it ; /// this implementation have bottleneck -> IntermediateThread /// </summary> /// <param name="threadCtx"></param> static void ThreadEntry(object threadCtx) { //Random rnd = new Random(); ThreadContext threadContext = threadCtx as ThreadContext; threadContext.ManagedID = threadContext.hThread.ManagedThreadId; while (!threadContext.StopThread) { IntermediateThread(threadContext); if (threadContext.Job != null) { PlanItem planned = threadContext.Job; if (planned.JobEntry(threadContext, planned) == 1) { Thread.Sleep(maxSuspend); } else { //if (planned.intervalType != IntervalType.withoutInterval) // Thread.Yield(); //Thread.Sleep(0000); } planned.ExucutingNow = false; } else { Console.WriteLine("sleep due job absent"); Thread.Sleep(maxSuspend); } } ExitThread(threadContext); }
/// <summary> /// All threads do it ; /// this implementation have bottleneck -> IntermediateThread /// </summary> /// <param name="threadCtx"></param> static void ThreadEntry(object threadCtx) { //Random rnd = new Random(); ThreadContext threadContext = threadCtx as ThreadContext; threadContext.ManagedID = threadContext.hThread.ManagedThreadId; while (!threadContext.StopThread) { if (threadContext.Job != null) { PlanItem planned = threadContext.Job; if (planned.JobEntry(threadContext, planned) == 1) { Thread.Sleep(maxSuspend); } else { Thread.Yield(); //Thread.Sleep(0000); } } else { Thread.Sleep(maxSuspend); } IntermediateThread(threadContext); } ExitThread(threadContext); }
static void IsolatedThreadEntry(object o) { ThreadContext ti = o as ThreadContext; ti.ManagedID = ti.hThread.ManagedThreadId; PlanItem pi = ti.Job; pi.JobEntry(ti, pi); ExitThread(ti); }