From c395b7d32b73496f73b9278b86f0ecc9507c1a70 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sat, 7 Dec 2019 22:41:20 -0600 Subject: [PATCH] Added IsRunning to SingleThreadTaskScheduler --- .../Async/SingleThreadTaskScheduler.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs b/IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs index 605e1dc6..85cced15 100644 --- a/IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs +++ b/IPA.Loader/Utilities/Async/SingleThreadTaskScheduler.cs @@ -17,15 +17,28 @@ namespace IPA.Utilities.Async private readonly BlockingCollection tasks = new BlockingCollection(); private readonly CancellationTokenSource exitTokenSource = new CancellationTokenSource(); + /// + /// Gets whether or not the underlying thread has been started. + /// + /// Thrown if this object has already been disposed. + public bool IsRunning + { + get + { + ThrowIfDisposed(); + return runThread.IsAlive; + } + } + /// /// Starts the thread that executes tasks scheduled with this /// /// Thrown if this object has already been disposed. - public void StartThread() + public void Start() { ThrowIfDisposed(); - runThread.Start(); + runThread.Start(this); } /// @@ -47,7 +60,6 @@ namespace IPA.Utilities.Async var retTasks = new List(); retTasks.AddRange(tasks); - Dispose(true); return retTasks; } @@ -64,7 +76,6 @@ namespace IPA.Utilities.Async tasks.CompleteAdding(); runThread.Join(); - Dispose(true); } ///