Win8 C# Metro dispatcher and RPC_E_WRONG_THREAD

末鹿安然 提交于 2019-12-08 01:50:55

问题


I am trying to build an application using the unofficial Google music api for .net in Windows 8 metro interface. I am loading the whole playlist

foreach (GoogleMusicPlaylist p in pls.UserPlaylists)
                lbPlaylists.Items.Add(p.Title);

and it comes up with this error

HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))

And I read around the internet and maybe I have to use dispatcher or something I am just generally confused.


回答1:


Use this

Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                foreach (GoogleMusicPlaylist p in pls.UserPlaylists)
                {
                    lbPlaylists.Items.Add(p.Title);
                }
            });


来源:https://stackoverflow.com/questions/12822392/win8-c-sharp-metro-dispatcher-and-rpc-e-wrong-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!