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

Task.Run should be used in DiskWriterQueue.cs #1490

Open
vuplea opened this issue Feb 19, 2020 · 0 comments
Open

Task.Run should be used in DiskWriterQueue.cs #1490

vuplea opened this issue Feb 19, 2020 · 0 comments

Comments

@vuplea
Copy link

vuplea commented Feb 19, 2020

Currently the code uses an overload of Task.Factory.StartNew that captures the TaskScheduler on which the constructor is executed. This immediately results in deadlock in single-threaded schedulers as the reader is blocking. Task.Run should be used instead (situation described in https://blog.stephencleary.com/2013/08/startnew-is-dangerous.html)

If leaving TaskCreationOptions.LongRunning is desired, then we must keep StartNew and specify the default task scheduler. This might be reasonable in library code, as we have to be more careful with the user's thread pool.

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

No branches or pull requests

2 participants