Skip to content

Should I turn on VSTHRD003 in my project? #1320

Answered by AArnott
MartyIX asked this question in Q&A
Discussion options

You must be logged in to vote

VSTHRD003 helps any application with a main thread avoid deadlocks if you ever have the need to synchronously block the main thread while waiting for async work to complete. It doesn't have to be a big application to matter. I can create a brand new WPF/WinForms app and demonstrate the hang that VSTHRD003 helps to avoid in perhaps 5 lines of code.

But if you have no main thread in your app (or if a library, if no application that uses your library will ever have a main thread), and/or if the application(s) will never block the main thread on async work that might need the main thread to complete their work, then ya, you can disable this rule.

And as the 'fix' for this often is to use Join…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MartyIX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants