TaskScheduler.FromCurrentSynchronizationContext

TaskScheduler.FromCurrentSynchronizationContextで、現在の同期コンテキストに紐付いたタスクスケジューラを生成できる。

TaskScheduler.FromCurrentSynchronizationContext メソッド (System.Threading.Tasks) | Microsoft Docs

Form1.csで、

と書く。
button1を押すと、

SynchronizationContextTaskSchedulerが生成される
SynchronizationContextTaskSchedulerが生成される

SynchronizationContextTaskSchedulerが生成される。

Sample/dotnet/TaskScheduler/FromCurrentSynchronizationContext/src/TaskScheduler_ at master · bg1bgst333/Sample · GitHub