在Windows Phone上调用带有yield返回的Web服务

发布于 2024-10-19 22:26:32 字数 1331 浏览 8 评论 0原文

我正在开发一个 Windows Phone 7 应用程序,我使用 Windows Live 身份验证来访问用户联系人。我有一个网络服务,具有以下方法:

public IEnumerable<LiveIDContact> GetContactsInformationYield(string LocationID, string DelegationToken)
    {
        string uriTemplate = "https://livecontacts.services.live.com/@L@{0}/rest/LiveContacts/Contacts";
        var xdoc = WindowsLiveContactAPIRequest(LocationID, DelegationToken, uriTemplate);
        var contacts = (from contact in xdoc.Descendants("Contact")
                        select contact).ToArray();

        foreach (var con in contacts)
        {
            RetrieveCID(LocationID, DelegationToken, con);
            LiveIDContact c = new LiveIDContact()
            {
                ID = con.Element("ID").Value,
                DisplayName = con.Element("Profiles").Element("Personal").Element("DisplayName").Value,
                CID = (con.Element("CID") != null ? con.Element("CID").Value : "")

            };

            yield return c;
        }

    }

我如何在应用程序中调用该方法:

public void GetContactInformationAsync()
    {
        LiveIDClient.GetContactsInformationYieldAsync(LocationID, ConsentToken);
    }

当我调用此方法并等待完成事件时,这就是问题所在。更新我的应用程序中的联系人列表需要 4 到 5 分钟。(性能问题)。有没有什么办法可以让每次收益回报时都发生一个事件?那么我可以更新该活动的列表吗?

我在任何地方都找不到答案,所以希望有人知道答案。

i'm developing a Windows Phone 7 app and I use Windows Live authentication to access the user contacts. I have a webservice, with the following method:

public IEnumerable<LiveIDContact> GetContactsInformationYield(string LocationID, string DelegationToken)
    {
        string uriTemplate = "https://livecontacts.services.live.com/@L@{0}/rest/LiveContacts/Contacts";
        var xdoc = WindowsLiveContactAPIRequest(LocationID, DelegationToken, uriTemplate);
        var contacts = (from contact in xdoc.Descendants("Contact")
                        select contact).ToArray();

        foreach (var con in contacts)
        {
            RetrieveCID(LocationID, DelegationToken, con);
            LiveIDContact c = new LiveIDContact()
            {
                ID = con.Element("ID").Value,
                DisplayName = con.Element("Profiles").Element("Personal").Element("DisplayName").Value,
                CID = (con.Element("CID") != null ? con.Element("CID").Value : "")

            };

            yield return c;
        }

    }

How i invoke the methode in the app:

public void GetContactInformationAsync()
    {
        LiveIDClient.GetContactsInformationYieldAsync(LocationID, ConsentToken);
    }

Here is the problem, when I invoke this methode and i wait on the complete event. It takes 4 to 5 minutes to update the list of contacts in my app.(Performance issue). Is there any way that an event occurs on every yield return ? So i can update my list from that event?

I couldn't find the answer anywhere so lets hope somebody knows the answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2024-10-26 22:26:32

这是为每个联系人进行单独的 HTTP 调用吗?如果是这样,那么我认为您只需要重新设计网络服务,以便它对每一百个联系人进行一次呼叫。

Is this making a separate HTTP call for every single contact? If so, then I think you simply need to redesign the webservice so that it makes a call for, say, every hundred contacts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文