Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Result after Task.WhenAll raise VSTHRD002 #693

Closed
ygalbel opened this issue Oct 8, 2020 · 0 comments · Fixed by #878
Closed

.Result after Task.WhenAll raise VSTHRD002 #693

ygalbel opened this issue Oct 8, 2020 · 0 comments · Fixed by #878
Milestone

Comments

@ygalbel
Copy link

ygalbel commented Oct 8, 2020

Bug description

When you have multiple tasks and you await them with await Task.WhenAll(t1, t2),
which problem can be if you call after that to t1.Result

I checked with sharplab and .Result version is smaller.

Repro steps

            Task<int> t1 = Task.FromResult(1);
            Task<int> t2 = Task.FromResult(2);

            await Task.WhenAll(t1, t2);

            var uuu = t1.Result;

Expected behavior

VSTHRD002 warning shouldn't be raised.

Actual behavior

VSTHRD002 warning is raised

  • Version used:
  • Application (if applicable):

Additional context

Add any other context about the problem here.

@ygalbel ygalbel changed the title .Result after Task.WhenAll rise VSTHRD103 .Result after Task.WhenAll raise VSTHRD103 Oct 11, 2020
bluetarpmedia added a commit to bluetarpmedia/vs-threading that referenced this issue Jul 12, 2021
…ia Task.WhenAll prior to the problematic member access (e.g. Result/Wait), and that the task variable has not been used in-between in a way that would invalidate this check.
@AArnott AArnott changed the title .Result after Task.WhenAll raise VSTHRD103 .Result after Task.WhenAll raise VSTHRD002 Aug 17, 2021
@AArnott AArnott added this to the v17.0 milestone Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants