VSSDK005 Use the JoinableTaskContext singleton
Code running within the Visual Studio process (and primary AppDomain)
should avoid creating a new instance of JoinableTaskContext,
as doing so may introduce deadlocks. Instead, everyone should share the
JoinableTaskContext instance offered by ThreadHelper.JoinableTaskContext.
This analyzer may be turned off for unit test projects, which may have a legitimate need to create a JoinableTaskContext.
Examples of patterns that are flagged by this analyzer
class MyCoolPackage : Package
{
void Foo()
{
var jtc = new JoinableTaskContext(); // this line flagged
}
}
Solution
Use the JoinableTaskContext available from the ThreadHelper class.
class MyCoolPackage : Package
{
void Foo()
{
var jtc = ThreadHelper.JoinableTaskContext;
}
}