Cannot await 'void' error

5.5k views Asked by At

I'm developing a WP7.1 app on VS2012.

I'd like to use Live SDK for uploading a file to Skydrive. However, when I'm implementing the event handler method which is given as a sample on msdn.com I got the error "Cannot await 'void' " here:

private async void btnSignin_SessionChanged(object sender, LiveConnectSessionChangedEventArgs e)
    {
        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            client = new LiveConnectClient(e.Session);
            LiveOperationResult operationResult = await client.GetAsync("me");

I already installed this (http://blogs.msdn.com/b/bclteam/archive/2012/10/22/using-async-await-without-net-framework-4-5.aspx?PageIndex=2) library, but it only resolved the problem with the "async" keyword.

1

There are 1 answers

2
Stephen Cleary On BEST ANSWER

LiveConnectClient is probably using the Event-based Asynchronous Pattern, which is not directly convertible to an awaitable method. You can wrap EAP into a Task by using TaskCompletionSource as described on MSDN here.