buvinghausen / TaskTupleAwaiter

Async helper library to allow leveraging the new ValueTuple data types in C# 7.0
MIT License
71 stars 10 forks source link

Fix TupleConfiguredTaskAwaitable to wait for all tasks #8

Closed maxbrodin closed 6 years ago

maxbrodin commented 6 years ago

It looks like a copy/paste bug inside TupleConfiguredTaskAwaitable costructors. When creating a new task using Task.WhenAll only 2 tasks passed out of 3, 4, 5. etc.

public Awaiter((Task<T1>, Task<T2>, Task<T3>) tasks, bool continueOnCapturedContext)
{
   _tasks = tasks;
   _whenAllAwaiter = Task.WhenAll(tasks.Item1, tasks.Item2)
      .ConfigureAwait(continueOnCapturedContext)
      .GetAwaiter();
}

Expected behavior is to wait for all tasks:

public Awaiter((Task<T1>, Task<T2>, Task<T3>) tasks, bool continueOnCapturedContext)
{
   _tasks = tasks;
   _whenAllAwaiter = Task.WhenAll(tasks.Item1, tasks.Item2, tasks.Item3)
      .ConfigureAwait(continueOnCapturedContext)
      .GetAwaiter();
}
jnm2 commented 6 years ago

Ouch! I am so sorry about that, that was me! Thanks for the fix!

@buvinghausen, you around?

jnm2 commented 6 years ago

@buvinghausen 🎉 Sorry to bug you!

buvinghausen commented 6 years ago

@jnm2 & @maxbrodin I'm so sorry I missed all the action going on over here version 1.2.0 has been pushed to NuGet

buvinghausen commented 6 years ago

@jnm2 you have been made collaborator on GitHub and Owner on NuGet

jnm2 commented 6 years ago

Thanks very much! I feel bad about the mistake. That was a super speedy response, no worries!

buvinghausen commented 6 years ago

@jnm2 Man when juggling so much stuff something like that was bound to happen just glad people like @maxbrodin is here to help contribute. Your library is awesome I use it heavily to fire off multiple 3rd party data lookups at the same time with disparate responses. I guess I never used it with just 3 tasks because I feel like I should have run into that issue earlier.

jnm2 commented 6 years ago

The ironic thing is that I did run into this issue very intermittently a couple weeks ago while writing a VS extension, and I confused myself and some other folks. So this brings some closure. I'll contribute some more tests, e.g. to make sure configured awaiting behaves properly.