locked
Task.GetAwaiter Method RRS feed

  • Question

  • Hi all,

    I saw the method in http://msdn.microsoft.com/en-us/library/system.threading.tasks.task.getawaiter.aspx

    the remark is "This method is intended for compiler user rather than use directly in code."

    intended for compliler user is what mean?

    In my code can I use this method, like this:

    Task.Run(async () =>
                    {
                       StorageFile file = await  StorageFile.GetFileFromPathAsync("aaaa");
    
                    }).GetAwaiter().GetResult();
    Thank you!

    自强不息,知行合一。

    Monday, September 30, 2013 2:16 AM

Answers

  •  await Task.Run(async () =>
                    {
                        await Task.Delay(5000);
                    });
    use this instead.

    • Proposed as answer by Dave SmitsMVP Monday, September 30, 2013 7:00 AM
    • Marked as answer by Anne Jing Monday, October 7, 2013 2:18 AM
    • Unmarked as answer by NEU_Simon Tuesday, October 8, 2013 1:53 AM
    • Marked as answer by NEU_Simon Tuesday, October 8, 2013 1:53 AM
    Monday, September 30, 2013 6:32 AM

All replies

  •  await Task.Run(async () =>
                    {
                        await Task.Delay(5000);
                    });
    use this instead.

    • Proposed as answer by Dave SmitsMVP Monday, September 30, 2013 7:00 AM
    • Marked as answer by Anne Jing Monday, October 7, 2013 2:18 AM
    • Unmarked as answer by NEU_Simon Tuesday, October 8, 2013 1:53 AM
    • Marked as answer by NEU_Simon Tuesday, October 8, 2013 1:53 AM
    Monday, September 30, 2013 6:32 AM
  • hi Oleg Kurzov,

    Thank you for your help!

    but I don't know why, can you tell me?

    Thank you!


    自强不息,知行合一。

    Tuesday, October 8, 2013 1:57 AM