/// <summary> /// Start execution, setting the top level work, /// enqueuing it and starting a shift to execute it. /// </summary> public void Start(WorkItem topLevelWorkItem) { _topLevelWorkItem = topLevelWorkItem; Dispatch(topLevelWorkItem, InitialExecutionStrategy(topLevelWorkItem)); var shift = SelectNextShift(); ShiftStarting?.Invoke(shift); shift.Start(); }
private void OnEndOfShift(WorkShift endingShift) { ShiftFinished?.Invoke(endingShift); WorkShift nextShift = null; while (true) { // Shift has ended but all work may not yet be done while (_topLevelWorkItem.State != WorkItemState.Complete) { // This will return null if all queues are empty. nextShift = SelectNextShift(); if (nextShift != null) { ShiftStarting?.Invoke(nextShift); nextShift.Start(); return; } } // If the shift has ended for an isolated queue, restore // the queues and keep trying. Otherwise, we are done. if (_isolationLevel > 0) { RestoreQueues(); } else { break; } } // All done - shutdown all shifts foreach (var shift in Shifts) { shift.ShutDown(); } }