public async Task AwaitingShouldRemoveSynchronizationContext() { // Arrange var contextRemover = new SynchronizationContextRemover(); // Act var contextBefore = SynchronizationContext.Current; await contextRemover; var contextAfter = SynchronizationContext.Current; // Assert Assert.NotNull(contextBefore); Assert.Null(contextAfter); }
/// <summary> /// Required initialization for using the async functionalities of the PalmSens SDK. /// The amount of simultaneous operations will be limited to prevent performance issues. /// When possible it will leave one core free for the UI. /// </summary> /// <param name="nCores">The number of CPU cores.</param> private void InitAsyncFunctionality(int nCores) { SynchronizationContextRemover.Init(nCores > 1 ? nCores - 1 : 1); }