A game framework written with osu! in mind.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ensure ThreadedTaskScheduler eventually disposes

+26 -1
+25
osu.Framework.Tests/Threading/ThreadedTaskSchedulerTest.cs
··· 36 36 37 37 Assert.AreEqual(target_count, runCount); 38 38 } 39 + 40 + [Test] 41 + public void EnsureEventualDisposalWithStuckTasks() 42 + { 43 + bool running = true; 44 + 45 + ManualResetEventSlim exited = new ManualResetEventSlim(); 46 + 47 + Task.Run(() => 48 + { 49 + using (var taskScheduler = new ThreadedTaskScheduler(4, "test")) 50 + { 51 + Task.Factory.StartNew(() => 52 + { 53 + while (running) 54 + Thread.Sleep(100); 55 + }, default, TaskCreationOptions.HideScheduler, taskScheduler); 56 + } 57 + 58 + exited.Set(); 59 + }); 60 + 61 + Assert.That(exited.Wait(30000)); 62 + running = false; 63 + } 39 64 } 40 65 }
+1 -1
osu.Framework/Threading/ThreadedTaskScheduler.cs
··· 87 87 tasks.CompleteAdding(); 88 88 89 89 foreach (var thread in threads) 90 - thread.Join(); 90 + thread.Join(TimeSpan.FromSeconds(10)); 91 91 92 92 tasks.Dispose(); 93 93 }