public QueuedTaskScheduler( QueuedTaskScheduler <TTask> .TaskProcessingRoutine routine, int paralleltasksCount) { this.isRunning = false; this.processingRoutine = routine; STPStartInfo stpStartInfo = new STPStartInfo(); stpStartInfo.set_MaxWorkerThreads(paralleltasksCount); stpStartInfo.set_MinWorkerThreads(0); ((WIGStartInfo)stpStartInfo).set_StartSuspended(true); this.processingStartInfo = stpStartInfo; this.processingThreadPool = new SmartThreadPool(this.processingStartInfo); this.processingGroup = this.processingThreadPool.CreateWorkItemsGroup(paralleltasksCount); // ISSUE: method pointer this.processingGroup.add_OnIdle(new WorkItemsGroupIdleHandler((object)this, __methodptr(processingGroup_OnIdle))); }
public UpdateTaskScheduler( Action <TTaskKey> taskRoutine, int maxRunningTasks, TimeSpan postponeTaskDelay, TimeSpan mandatorySchedulerDelay) { this.taskRoutine = taskRoutine; this.postponeTaskDelay = postponeTaskDelay; this.mandatorySchedulerDelay = mandatorySchedulerDelay; this.ongoingChangesCounter = 0; this.ongoingTasks = new HashSet <UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask>((IEqualityComparer <UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask>)UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask.IdentityComparer.Instance); this.scheduledTasks = new PriorityQueue <UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask>((IComparer <UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask>)UpdateTaskScheduler <TTaskKey, TCallbackArg> .ScheduledTask.SchedulingComparer.Instance); this.schedulerThread = new Thread(new ThreadStart(this.SchedulerRoutine)); this.schedulerThread.IsBackground = true; this.schedulerThread.Start(); STPStartInfo stpStartInfo = new STPStartInfo(); stpStartInfo.set_MaxWorkerThreads(maxRunningTasks); stpStartInfo.set_MinWorkerThreads(0); ((WIGStartInfo)stpStartInfo).set_StartSuspended(false); this.processingThreadPool = new SmartThreadPool(stpStartInfo); this.processingGroup = this.processingThreadPool.CreateWorkItemsGroup(maxRunningTasks); }