locked
await SuspensionManager.RestoreAsync async error RRS feed

  • Question

  • I am getting this error message and I can't figure out why.

    The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.

    The code is:

    await SuspensionManager.RestoreAsync();

    The project is a Windows Phone 8.1 

    Tuesday, March 24, 2015 3:38 PM

Answers

  • What method have you put the "await SuspensionManager.RestoreAsync()" into? Every method that you use await in must be marked as async.

    e.g.

    public async void Foo() {
      await SuspensionManager.RestoreAsync();
    }

    If you omit the keyword async in front of the return type you will get the error message you have posted.

    • Proposed as answer by Jamles Hez Wednesday, March 25, 2015 5:22 AM
    • Marked as answer by bionicman08 Thursday, March 26, 2015 10:34 AM
    Tuesday, March 24, 2015 3:49 PM