Browse Source

Added IsRunning to SingleThreadTaskScheduler

4.0.0-beta
Anairkoen Schno 5 years ago
parent
commit
d611ad0e46
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 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>
/// Starts the thread that executes tasks scheduled with this <see cref="TaskScheduler"/>
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this object has already been disposed.</exception>
public void StartThread()
public void Start()
{
ThrowIfDisposed();
runThread.Start();
runThread.Start(this);
}
/// <summary>
@ -47,7 +60,6 @@ namespace IPA.Utilities.Async
var retTasks = new List<Task>();
retTasks.AddRange(tasks);
Dispose(true);
return retTasks;
}
@ -64,7 +76,6 @@ namespace IPA.Utilities.Async
tasks.CompleteAdding();
runThread.Join();
Dispose(true);
}
/// <summary>


Loading…
Cancel
Save