You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I pushed the threading version for a certain project. Now, the warning VSTHRD010 is coming up for certain parts of code despite the call to JoinableTaskFactory.SwitchToMainnThreadAsync.
Repro steps
public static async Task<bool> TestMethod(JoinableTaskFactory jtf)
{
await jtf.SwitchToMainThreadAsync(VsShellUtilities.ShutdownToken);
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
// do something that requires main thread
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
}
Expected behavior
No warning should appear.
Actual behavior
Warning appeared, and we have to suppress the warning. Despite switching to main thread.
Version used: 17.10.41
The text was updated successfully, but these errors were encountered:
kfam98
changed the title
VSTHRD010 warning despite call to JoinableTaskFactory.SwitchToMainnThreadAsync
VSTHRD010 warning despite call to JoinableTaskFactory.SwitchToMainThreadAsync
Mar 29, 2024
I agree this shouldn't be happening. Your sample code is about as simple as it gets for what should work however. In fact it's equivalent to this test we have:
Bug description
I pushed the threading version for a certain project. Now, the warning VSTHRD010 is coming up for certain parts of code despite the call to
JoinableTaskFactory.SwitchToMainnThreadAsync
.Repro steps
Expected behavior
No warning should appear.
Actual behavior
Warning appeared, and we have to suppress the warning. Despite switching to main thread.
The text was updated successfully, but these errors were encountered: