LiveConnectClient缺少事件处理程序Live SDK 5.3 WP8

时间:2013-01-14 15:17:36

标签: c# windows-phone-8

你好:)我明白了。

问题: 当我尝试实例化LiveConnectClient然后尝试访问事件时:GetCompleted 没有显示在LiveConnectClient中的所有示例,在我看到的所有示例中,即使是在这里的人也在使用它。这不是唯一一个正在发生这种情况的课程,它也发生在LiveAuthClient上,即使是网上的帖子也没有发生任何事件。

我试图重新安装Vs2012和sdk wp8并从头开始直播sdk但还没有解决它

for refrence i使用此示例来查看我是否可以使用它:

    //event triggered when Skydrive sign in status is changed
    private void btnSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
    {
        //if the user is signed in
        if (e.Status == LiveConnectSessionStatus.Connected)
        {
            session = e.Session;

            client = new LiveConnectClient(e.Session);
            infoTextBlock.Text = "Accessing SkyDrive...";

            //get the folders in their skydrive

            client.GetCompleted +=
                new EventHandler<LiveOperationCompletedEventArgs>(btnSignin_GetCompleted);

            client.GetAsync("me/skydrive/files?filter=folders,albums");
        }

        //otherwise the user isn't signed in
        else
        {
            infoTextBlock.Text = "Not signed in.";
            client = null;
        }

    }

我没有运气解决它并且没有想法。因此,我希望你们中的一个男孩可以对此有所了解,或者用露水的方式伸出援助之手:)

提前谢谢。如果这是长篇大论,我会道歉。

关于jens

1 个答案:

答案 0 :(得分:2)

事实上,似乎已在最新版本的SDK中删除了这些事件。但是,由于async / await关键字,你不需要它们。首先,将您的方法标记为async,然后使用GetAsync关键字调用await方法。然后将您通常放在GetCompleted事件中的代码放在后面:

private async void btnSignIn_SessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
{
    //if the user is signed in
    if (e.Status == LiveConnectSessionStatus.Connected)
    {
        session = e.Session;

        client = new LiveConnectClient(e.Session);
        infoTextBlock.Text = "Accessing SkyDrive...";

        //get the folders in their skydrive
        var result = await client.GetAsync("me/skydrive/files?filter=folders,albums");

        // Do here what you would normally do in btnSignin_GetCompleted
    }

    //otherwise the user isn't signed in
    else
    {
        infoTextBlock.Text = "Not signed in.";
        client = null;
    }

}