none
Async method RRS feed

  • Question

  • Hi,

    I am developing console application for schedulers.

    I have three methods,  2 are async. methods and 1 is sync. method.

    My scenario is the 3 rd method should execute after executed the both two async. methods.

    because, based on those methods results, again I needs to do some functionality. 

    Here, I can't keep those both async. methods as sync. methods because, both will take much time to complete their executions.

    please share your idea.

    how can I can execute the 3rd methods, after this both async. methods are executed.

    Thanks!

    Wednesday, June 20, 2018 6:20 AM

Answers

  • I found answer:

     Task t1= Task.Run(() => method1());

     Task t2= Task.Run(() => method2());

     await Task.WhenAll(t1, t2);

      method3().Wait();

    • Marked as answer by BrettoAbraham Wednesday, June 20, 2018 10:11 AM
    Wednesday, June 20, 2018 10:11 AM