MTA calling STA
-
I am really turning nuts! I have the following problem: I have a library that is MTA by design - and I cannot modify it, I have only the assambly. So far so good, but my application is a WPF application. And that in turn is STA by design. So my simple question: How can both talk to each other? More precisely, there are no problems unless callbacks from the MTA-library are executed. I would like to give some feedback through the GUI, but nothing happens (ok, at least there is a caught exception that the GUI an only be modified from a STA thread... fine, so my delegate is still executed out of some library's thread) The simple delegate does not work, implementing a wrapper with some event does not either. Posting a "real" Windows Message and grabbing data out of the wrapper would work, but that cannot be the best answer for my problem... can it?? Any help appreciated to make my code some kind of more professional. ;P Don Rolando
-
I am really turning nuts! I have the following problem: I have a library that is MTA by design - and I cannot modify it, I have only the assambly. So far so good, but my application is a WPF application. And that in turn is STA by design. So my simple question: How can both talk to each other? More precisely, there are no problems unless callbacks from the MTA-library are executed. I would like to give some feedback through the GUI, but nothing happens (ok, at least there is a caught exception that the GUI an only be modified from a STA thread... fine, so my delegate is still executed out of some library's thread) The simple delegate does not work, implementing a wrapper with some event does not either. Posting a "real" Windows Message and grabbing data out of the wrapper would work, but that cannot be the best answer for my problem... can it?? Any help appreciated to make my code some kind of more professional. ;P Don Rolando
When you get a callback from the MTA library, just post to the Dispatcher of your WPF app to do the UI-related work. See MSDN's WPF Threading Model[^] for more info.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Upon this disciple I'll build my new religion? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
I am really turning nuts! I have the following problem: I have a library that is MTA by design - and I cannot modify it, I have only the assambly. So far so good, but my application is a WPF application. And that in turn is STA by design. So my simple question: How can both talk to each other? More precisely, there are no problems unless callbacks from the MTA-library are executed. I would like to give some feedback through the GUI, but nothing happens (ok, at least there is a caught exception that the GUI an only be modified from a STA thread... fine, so my delegate is still executed out of some library's thread) The simple delegate does not work, implementing a wrapper with some event does not either. Posting a "real" Windows Message and grabbing data out of the wrapper would work, but that cannot be the best answer for my problem... can it?? Any help appreciated to make my code some kind of more professional. ;P Don Rolando
-
When you get a callback from the MTA library, just post to the Dispatcher of your WPF app to do the UI-related work. See MSDN's WPF Threading Model[^] for more info.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Upon this disciple I'll build my new religion? The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
You are my man! Thanks a lot, that was it! The Dispatcher... argh, of course. :)
-
led mike
Thank a lot, but Judah's post gave me already the answer I searched for. (And it was about the same as the German page was about)