Add public IThreadPoolWorkItem (#20387)
authorStephen Toub <stoub@microsoft.com>
Thu, 18 Oct 2018 10:01:49 +0000 (06:01 -0400)
committerGitHub <noreply@github.com>
Thu, 18 Oct 2018 10:01:49 +0000 (06:01 -0400)
commit0c7781113cec74ed69aa6a38f9a3e845f40c3680
tree8c49e07c37174911c65706177a9589ef7b084ee2
parentc29b1261a367816a6802df4fc0e4939d047ee919
Add public IThreadPoolWorkItem (#20387)

- Changes the internal IThreadPoolWorkItem to be public, removing the legacy ThreadAbortException from it (which was specific to Task, anyway).
- Removes the IThreadPoolWorkItem implementation from Task, so that devs can't write code like `ThreadPool.UnsafeQueueUserWorkItem(task);` or `((IThreadPoolWorkItem)task).Execute();`, both of which could end up doing a variety of bad things that could show up in a variety of ways, some discoverable, some less so.
- Adds an internal UnsafeQueueUserWorkItemInternal that takes object so that it can be passed either an IThreadPoolUserWorkItem or a Task,
- Changes the ThreadPool's queues to be in terms of object instead of IThreadPoolWorkItem
- Changes the dispatch loop to type check for IThreadPoolWorkItem or Task so that both remain supported.
src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs
src/System.Private.CoreLib/shared/System/Threading/SemaphoreSlim.cs
src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/ThreadPoolTaskScheduler.cs
src/System.Private.CoreLib/src/System/Threading/ThreadPool.cs
src/System.Private.CoreLib/src/System/Threading/Timer.cs