|
@ -17,15 +17,28 @@ namespace IPA.Utilities.Async |
|
|
private readonly BlockingCollection<Task> tasks = new BlockingCollection<Task>(); |
|
|
private readonly BlockingCollection<Task> tasks = new BlockingCollection<Task>(); |
|
|
private readonly CancellationTokenSource exitTokenSource = new CancellationTokenSource(); |
|
|
private readonly CancellationTokenSource exitTokenSource = new CancellationTokenSource(); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets whether or not the underlying thread has been started.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <exception cref="InvalidOperationException">Thrown if this object has already been disposed.</exception>
|
|
|
|
|
|
public bool IsRunning |
|
|
|
|
|
{ |
|
|
|
|
|
get |
|
|
|
|
|
{ |
|
|
|
|
|
ThrowIfDisposed(); |
|
|
|
|
|
return runThread.IsAlive; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Starts the thread that executes tasks scheduled with this <see cref="TaskScheduler"/>
|
|
|
/// Starts the thread that executes tasks scheduled with this <see cref="TaskScheduler"/>
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <exception cref="InvalidOperationException">Thrown if this object has already been disposed.</exception>
|
|
|
/// <exception cref="InvalidOperationException">Thrown if this object has already been disposed.</exception>
|
|
|
public void StartThread() |
|
|
|
|
|
|
|
|
public void Start() |
|
|
{ |
|
|
{ |
|
|
ThrowIfDisposed(); |
|
|
ThrowIfDisposed(); |
|
|
|
|
|
|
|
|
runThread.Start(); |
|
|
|
|
|
|
|
|
runThread.Start(this); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
@ -47,7 +60,6 @@ namespace IPA.Utilities.Async |
|
|
var retTasks = new List<Task>(); |
|
|
var retTasks = new List<Task>(); |
|
|
retTasks.AddRange(tasks); |
|
|
retTasks.AddRange(tasks); |
|
|
|
|
|
|
|
|
Dispose(true); |
|
|
|
|
|
return retTasks; |
|
|
return retTasks; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -64,7 +76,6 @@ namespace IPA.Utilities.Async |
|
|
|
|
|
|
|
|
tasks.CompleteAdding(); |
|
|
tasks.CompleteAdding(); |
|
|
runThread.Join(); |
|
|
runThread.Join(); |
|
|
Dispose(true); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|