Class WorkShift
The dispatcher needs to do different things at different, non-overlapped times. For example, non-parallel tests may not be run at the same time as parallel tests. We model this using the metaphor of a working shift. The WorkShift class associates one or more WorkItemQueues with one or more TestWorkers.
Work in the queues is processed until all queues are empty and all workers are idle. Both tests are needed because a worker that is busy may end up adding more work to one of the queues. At that point, the shift is over and another shift may begin. This cycle continues until all the tests have been run.
public class WorkShift
- Inheritance
-
WorkShift
- Inherited Members
Constructors
WorkShift(string)
Construct a WorkShift
public WorkShift(string name)
Parameters
name
string
Properties
HasWork
Gets a bool indicating whether this shift has any work to do
public bool HasWork { get; }
Property Value
IsActive
Gets a flag indicating whether the shift is currently active
public bool IsActive { get; }
Property Value
Name
The Name of this shift
public string Name { get; }
Property Value
Methods
AddQueue(WorkItemQueue)
Add a WorkItemQueue to the shift, starting it if the shift is currently active.
public void AddQueue(WorkItemQueue queue)
Parameters
queue
WorkItemQueue
Assign(TestWorker)
Assign a worker to the shift.
public void Assign(TestWorker worker)
Parameters
worker
TestWorker
Cancel(bool)
Cancel (abort or stop) the shift without completing all work
public void Cancel(bool force)
Parameters
force
booltrue if the WorkShift should be aborted, false if it should allow its currently running tests to complete
EndShift()
End the shift, pausing all queues and raising the EndOfShift event.
public void EndShift()
ShutDown()
Shut down the shift.
public void ShutDown()
Start()
Start or restart processing for the shift
public void Start()
Events
EndOfShift
Event that fires when the shift has ended
public event ShiftChangeEventHandler? EndOfShift