/// <summary /// Instantiates a worker group with specified maximum concurrency and external progress reporting. Progress /// will be reported on the thread instantiating the ProgressContext used. /// </summary> /// <param name="maxConcurrent">The maximum number of worker threads active at any one time</param> /// <param name="progress">The ProgressContext that receives progress notifications</param> public WorkerGroup(int maxConcurrent, IProgressContext progress) { if (progress == null) { throw new ArgumentNullException("progress"); } _concurrencyControlSemaphore = Resolve.Portable.Semaphore(maxConcurrent, maxConcurrent); _maxConcurrencyCount = maxConcurrent; _singleThread = Resolve.Portable.SingleThread(); FirstError = new FileOperationContext(String.Empty, ErrorStatus.Success); progress.NotifyLevelStart(); Progress = new WorkerGroupProgressContext(progress, _singleThread); }
private void DisposeInternal() { NotifyFinishedInternal(); if (_concurrencyControlSemaphore != null) { _concurrencyControlSemaphore.Dispose(); _concurrencyControlSemaphore = null; } if (_singleThread != null) { _singleThread.Dispose(); _singleThread = null; } }
public WorkerGroupProgressContext(IProgressContext progress, ISingleThread singleThread) { _progress = progress; _singleThread = singleThread; }