Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid raising unnecessary ObjectDisposedException when accessing SemaphoreSlim object #277

Open
wants to merge 2 commits into
base: master
from

Conversation

@pmcilreavy
Copy link

pmcilreavy commented Apr 10, 2018

Rather than raising unnecessary ObjectDisposedExceptions we can reflect on the SemaphoreSlim object and check if it is already disposed. Raising lots of unnecessary exceptions (as can happen here) is expensive and impacts performance. With this change we can avoid those unnecessary exceptions.

@JeremyCade

This comment has been minimized.

Copy link
Collaborator

JeremyCade commented Apr 10, 2018

@pmcilreavy Could you provide an example where the cancellationSemaphore would be disposed raising an exception?

@JeremyCade JeremyCade self-assigned this Apr 10, 2018
@pmcilreavy

This comment has been minimized.

Copy link
Author

pmcilreavy commented Apr 10, 2018

Sure, I made a gist (which you can run with LinqPad) which recreates the issue using non-nimbus (but conceptually identical) code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.