diff --git a/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs b/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs index 02f76fca36..acf0620439 100644 --- a/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs +++ b/osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs @@ -83,5 +83,28 @@ public void EnsureScheduledTaskReturnsOnDisposal() Assert.That(run.Wait(30000)); Assert.That(exited.Wait(30000)); } + + [Test] + [Repeat(1000)] + public void QueueAndDisposeStressTest() + { + ThreadedTaskScheduler scheduler = new ThreadedTaskScheduler(1, string.Empty); + + Thread disposeThread = new Thread(() => + { + scheduler.Dispose(); + }) { IsBackground = true }; + + Thread queueThread = new Thread(() => + { + Task.Factory.StartNew(() => { }, CancellationToken.None, TaskCreationOptions.HideScheduler, scheduler); + }) { IsBackground = true }; + + disposeThread.Start(); + queueThread.Start(); + + disposeThread.Join(); + queueThread.Join(); + } } }