Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top