Search code examples
.netexecutioncontext

Do .net events flow the current ExecutionContext?


I see some code optimization about suppressing execution context flow almost immediately before a += style .net event registration (C#)

        EnsureExecutionContextSuppressed();
        _eventArgs.Completed += OnEventArgsCompleted;

Why? Is that because .net events normally flow the current execution context?


Solution

  • .NET events are simply delegate invocations. They behave like method calls. There is zero impact on the execution context.