System.Runtime.InteropServices.COMException when retrieving a RSS feed asynchronously
-
Donnerstag, 20. September 2012 18:15
I'm trying to build a windows 8 metro app. A small RSS reader which retrieves feeds.
Therefor I try to get a feed async.
Windows.Web.AtomPub.AtomPubClient client = new Windows.Web.AtomPub.AtomPubClient(); client.RetrieveFeedAsync(new Uri("http://MyURI/index.rss")).Completed += completed;
Here is the callback function:
private void completed(IAsyncOperationWithProgress<Windows.Web.Syndication.SyndicationFeed, Windows.Web.Syndication.RetrievalProgress> asyncInfo, AsyncStatus asyncStatus);
Ok. Now my problem.
As long as I try to access object within my callback function, everything is working fine. But if I try to access objects of my class (in which the callback function is located) I got a COMException.
I try something like this: this.MyCollection.Add(...). I'm building a feedItem which I add to a collection within my class.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.
The strange thing is, that this access is working every second run of my app.
I don't understand whats going wrong here.
Does someone got a hint for me please?
Thanks a lot!
Alle Antworten
-
Donnerstag, 20. September 2012 21:55
Hi Catscratch29,
du hast hier irgendwo einen Thread übergreifenden zugriff.
Meine Vermutung wäre die Collection. Collections sind von sich aus nicht Thread sicher.Du kannst hier im übrigen hier auch Deutsch Posten. Das macht das Beantworten der Fragen für die meisten einfacher.
MFG
Björn
-
Freitag, 21. September 2012 06:19
Ja, es passiert auch beim Zugriff auf die Collection. Wie mach ich das ganze dann Thread sicher? Einfach ein Setter wird ja nicht reichen. Der würde dann ja auch aus dem falschen Thread gecalled.
-
Freitag, 21. September 2012 07:59
- Bearbeitet PalinMicrosoft Community Contributor Freitag, 21. September 2012 08:00
- Als Antwort markiert Robert BreitenhoferMicrosoft Contingent Staff, Moderator Donnerstag, 18. Oktober 2012 14:14
-
Freitag, 21. September 2012 11:27
Super! Danke!
BlockingCollection kannte ich gar nicht, aber damit funktioniert es.
grüße

