-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update scheduling-threads.md added an example code #40739
base: main
Are you sure you want to change the base?
Conversation
Added an example code with description.
@dotnet-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @victoravt
This is an important sample to add. Thank you.
I had a few comments for updates, and then this is ready to merge.
|
||
The following code will output arbitrary results on each execution. But common sequence patters of priorities being ran could be observed after running multiple times and analyzing the outputs. | ||
|
||
```c# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For samples, we've been moving toward including samples as code files using the :::
code extension. That enables our CI system to validate the code. Can you move the sample code into a project and include the code here?
Thread t0 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t1 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t2 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t3 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t4 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t5 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t6 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t7 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); | ||
Thread t8 = new Thread(() => { new ThreadWithCallback(Callback).Process(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a log of opportunity to refactor this so it's got less repeated code. Maybe store the threads in an array and loop through the creation, setting priority, and start code?
Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
Summary
The example demonstrates the prioritization of threads in action and gives code base for readers to copy and experiment with.
Describe your changes here.
Added an example code with description.
Fixes #Issue_Number (if available)
No issue.
Internal previews