Asynchronus coding question.

Dave Gray 586 Reputation points
2022-10-12T13:16:57.31+00:00

Hello

Can anyone please tell me why the code on lines 7 & 9 does not get executed?

I'm basically pulling back a list of devices using the LogicMonitor SDK and there is no synchronous version of GetAllAsync (in the SDK) .

This is a cut-down version of my code in VS2022 which also does not execute after the line 5.

Is there a better/proper way to do this?

Thanks

249680-async-issue.png

Developer technologies | C#
{count} votes

Accepted answer
  1. João Ludovico 81 Reputation points
    2022-10-12T14:04:06.88+00:00

    Hi,

    You can do this on line 3:

    List<Device> devices = await GetDevices();  
    

    Then you don't need line 4 and simple have:

     Console.WriteLine(devices.GetType());  
      
    Console.WriteLine("Hello");  
    

    I think this should work.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Dave Gray 586 Reputation points
    2022-10-12T15:48:13.92+00:00

    249750-async-issue2.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.