Browse Source

Added IsRunning to SingleThreadTaskScheduler

pull/46/head
Anairkoen Schno 5 years ago
parent
commit
c395b7d32b
1 changed files with 15 additions and 4 deletions
  1. +15
    -4
      IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs

+ 15
- 4
IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs View File

@ -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>


Loading…
Cancel
Save