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

Docs: Not clear of SemaphoreSlim usage with ConcurrentQueue #8673

Closed
IndikaUdagedara opened this issue Sep 24, 2018 — with docs.microsoft.com · 3 comments
Closed
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue
Milestone

Comments

Copy link

ConcurrentQueue handles all synchronization internally, so it's not clear why SemaphoreSlim is used here. Can you please add a sentence describing why it is required?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@guardrex
Copy link
Collaborator

guardrex commented Sep 24, 2018

I can't say outside of their goal to base it on QueueBackgroundWorkItem. SemaphoreSlim is used in their BackgroundTaskQueue example. They plan to port QueueBackgroundWorkItem to Core for 3.0. The topic sample was based on a prototype, and there's an issue for that, as well. I recommend that you ask over on the aspnet/Hosting issue (it's still open for discussion), and one of the engineers will probably answer.

https://github.com/aspnet/Hosting/issues/1280 You should probably ask here.
#3352 You can see the prototype for the topic sample here.

@guardrex guardrex added Source - Docs.ms Docs Customer feedback via GitHub Issue P4 labels Sep 24, 2018
@guardrex guardrex added this to the Backlog milestone Sep 24, 2018
@pr3sto
Copy link

pr3sto commented Oct 30, 2018

TryDequeue in ConcurrentQueue returns false if there are no items in the queue. So SemaphoreSlim is used here to block executing of ExecuteAsync method until some workItem is pushed in QueueBackgroundWorkItem method.
Probably you can use BlockingCollection here instead.
Anyway it is just an example, as @guardrex mentioned - it is taken from aspnet/Hosting#1280

@Rick-Anderson
Copy link
Contributor

Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

4 participants