Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ExecutionContext.SuppressFlow() suppression state does not flow #16307
Because ExecutionContext does not come for free, and saving/restoring it has measurable overheads,
However, the observed behavior of this code is that after each async call,
I.e. the observed behavior is that while the execution context successfully is suppressed, and we resume execution without restoring the execution context, the suppression state is not restored, requiring us to suppress execution context all over again in order to get it really suppressed.
This doesn't seem good. Calling ExecutionConext.IsFlowSuppressed() and ExecutionContext.SuppressFlow() like this isn't free in either lines of code nor CPU and memory!
The behavior I actually believe should happen is that the suppression state should be preserved around the async call, meaning there need be no further calls to EnsureSuppressed();
That would better fulfil what I believe the intent of ExecutionContext.SuppressFlow() is: to suppress flow of the entire context for the current 'logical execution operation'.
And then it also might be feasible to undo the suppression correctly (currently it seems like it is a conceptual mess to do this!)