public async Task TestToAsyncContext() { await AsTask.ToContext(_contextTests1Id); Console.WriteLine(AsTask.WhereAmI()); Assert.True(AsTask.IsThreadContext(_contextTests1Id), $"This is not the AsContext({_contextTests1Id})!"); }
public async Task TestMoreSwitching() { for (var i = 0; i < 1000; i++) { await TestSwitchingToContexts(); } for (var i = 0; i < 1000; i++) { await AsTask.ToMainContext(); Assert.True(AsTask.IsMainContext()); } for (var i = 0; i < 1000; i++) { await AsTask.ToBackgroundContext(); Assert.True(AsTask.IsBackgroundContext()); } for (var i = 0; i < 1000; i++) { await AsTask.ToContext(_contextTests1Id); Assert.True(AsTask.IsThreadContext(_contextTests1Id)); } for (var i = 0; i < 1000; i++) { await AsTask.ToStaticThreadPool(); Assert.True(AsTask.IsStaticThreadPool()); } for (var i = 0; i < 1000; i++) { await AsTask.ToDynamicThreadPool(); Assert.True(AsTask.IsDynamicThreadPool()); } }