System.Runtime.InteropServices.COMException异步检索RSS订阅源

问题描述:

我试图构建一个Windows 8 metro应用程序。一个检索提要的小型RSS阅读器。System.Runtime.InteropServices.COMException异步检索RSS订阅源

因此,我尝试获得异步提要。

Windows.Web.AtomPub.AtomPubClient client = new Windows.Web.AtomPub.AtomPubClient(); 
client.RetrieveFeedAsync(new Uri("http://MyURI/index.rss")).Completed += completed; 

这里是回调函数:

private void completed(IAsyncOperationWithProgress<Windows.Web.Syndication.SyndicationFeed, Windows.Web.Syndication.RetrievalProgress> asyncInfo, AsyncStatus asyncStatus); 

确定。现在我的问题。

只要我尝试访问我的回调函数内的对象,一切工作正常。但是,如果我尝试访问我的类的对象(其中回调函数位于),我得到一个COMException。 我尝试这样:this.MyCollection.Add(...)。我正在构建一个feedItem,并将其添加到我的课程中的一个集合中。

An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code 

Additional information: Eine Schnittstelle, die für einen anderen Thread marshalled war, wurde von der Anwendung aufgerufen. (Ausnahme von HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)) 

If there is a handler for this exception, the program may be safely continued. 

奇怪的是,这个访问正在我的应用程序每秒运行一次。

我不明白这里出了什么问题。

请问有人给我提示吗?

非常感谢!

+0

好的。解决方案:BlockingCollection。 – Catscratch

好的。解决方案是一个BlockingCollection。这是线程安全的。