Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

Fix usage of ExecutionContext in netstandard2.0#2951

Merged
colombod merged 2 commits into
dotnet:mainfrom
shyamnamboodiripad:executioncontext
Apr 28, 2023
Merged

Fix usage of ExecutionContext in netstandard2.0#2951
colombod merged 2 commits into
dotnet:mainfrom
shyamnamboodiripad:executioncontext

Conversation

@shyamnamboodiripad

@shyamnamboodiripad shyamnamboodiripad commented Apr 28, 2023

Copy link
Copy Markdown
Contributor
  • Always pass a copy of the captured ExecutionContext to the ExecutionContext.Run API. Without this, executing this code atop net472 results in the error mentioned in Trying to host ProxyKernel within a .NET Framework assembly results in an InvalidOperationException #2775. It seems like the .NET Framework version of this API requires that the same ExecutionContext instance should not be passed to ExecutionContext.Run more than once. See this note in the documentation under the The following is applicable to .NET Framework only section.

  • Also fixes a NullReferenceException that is encountered during the KernelScheduler's disposal if cancellation is triggered after the blocking collection is disposed. This exception is not encountered if we switch the order of execution to trigger cancellation before the blocking collection is disposed.

…text.Run API.

This is required to make the API work correctly when running against .NET Framework.
…perations BlockingCollection after _schedulerDisposalSource.Cancel() is called.

Also dispose _schedulerDisposalSource.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants