user673906
user673906

Reputation: 847

Win8 C# Metro dispatcher and RPC_E_WRONG_THREAD

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.

Upvotes: 2

Views: 2418

Answers (1)

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39988

Use this

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

Upvotes: 6

Related Questions