1

I have async method like this:

public static async void SendInfo(List<MyType> list)
{
   var tasks = list.Select(i => SendAsync(i));
   await Task.WhenAll(tasks); // breakpoint1
}

public static async Task SendAsync(MyType item)
{
   Input input = GetInput(item); //preparation data
   Client client = new Client();
   Output output = await client.CreateInput(input); //breakpoint2
   if (output.Status == Status.Success) //breakpoint3
   {  //Other code }
}

Input, Output, Client - proxy-classes from remote API service. Is it possible to debug method SendAsync after condition if? In my case breakpoint3 can not be reached. Debug instance ends when I click "Step into" on line with await client.CreateInput(input)

Sv__t
  • 212
  • 5
  • 10
  • What happens if you remove all breakpoints except for `breakpoint3`, and just run the program? – Daniel A. Thompson Aug 15 '18 at 14:59
  • No, because `SendInfo` is an `async void` method, control is returned from `SendAsync` back to `SendInfo` on the first `await` – Camilo Terevinto Aug 15 '18 at 14:59
  • 4
    Your first method should be `async Task` rather than `async void`. https://stackoverflow.com/questions/12144077/async-await-when-to-return-a-task-vs-void – gunr2171 Aug 15 '18 at 15:01

0 Answers0