Created
February 1, 2019 13:38
-
-
Save kevingosse/2592ee3da25ac1d44ed7d3c64b34f2a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void QueueTask(Task task) | |
{ | |
MutateState(task); | |
var newScheduler = new ThreadPoolTaskScheduler(); | |
typeof(Task).GetField("m_taskScheduler", BindingFlags.Instance | BindingFlags.NonPublic) | |
.SetValue(task, newScheduler); | |
ThreadPool.UnsafeQueueUserWorkItem(t => newScheduler.ExecuteTask((Task)t), task); | |
} | |
private void ExecuteTask(Task t) | |
{ | |
TryExecuteTask(t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment