Skip to content

Conversation

@George-Shaw
Copy link

Fix for issue #204.

AsynchronousWorker called Task.Factory.StartNew without a TaskScheduler argument. The default behaviour inherits the task scheduler from the parent task. If the parent task was explicitly scheduled in a particular synchronisation context (e.g. the main thread), the worker tasks would use that same context. This was incorrect - worker tasks should always be in background threads.

To correct this, I am explicitly specifying TaskScheduler.Default for scheduling the worker tasks, so they always run on thread pool threads.

This is the most minimal fix for the issue. It would probably be better to use Task.Run instead of Task.Factory.StartNew.

AsynchronousWorker called Task.Factory.StartNew without a TaskScheduler
argument. The default behaviour inherits the task scheduler from the
parent task. If the parent task was explicitly scheduled in a particular
synchronisation context (e.g. the main thread), the worker tasks would
use that same context. This was incorrect - worker tasks should always
be in background threads.

To correct this, I am explicitly specifying TaskScheduler.Default for
scheduling the worker tasks, so they always run on thread pool threads.
@cit-pr-commenter
Copy link

PR Security Update

All commits in this PR up to and including 625c149 have been reviewed and marked safe by SDLC security. For any questions, please reach out to #ci-for-external-contributors-collab on Slack.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant