Sign in to follow this  
maxdub

[.net] [SOLVED] Win32 DLL hosting WPF content

Recommended Posts

hey all, I'm having trouble coaxing a win32 dll in to drawing WPF content. The problem lies in making my dll (or at least wpf rendering part of the dll) single threaded. Normally if I want to make a Win32 window draw WPF content I would just throw the [System::STAThreadAttribute] in front of the main entrance point for the app to make the entire application single threaded. My problem is that my dll only has two functions exported, init and shutdown. Init calls the Init of a wrapper class for my WPF content which is suppose to create the window and draw the content. The problem is that somewhere along the line I am suppose to be setting the STA attribute on my thread and I'm not really sure where since all the WPF interp documentation always just talks about placing [System::STAThreadAttribute] in front of the entrance point. In short, My application's pipeline is the following, I need to know where/how to set the thread to be STA. -- native c++ app -- my wpf interop dll (wpf wrapper class w/ init function) -- wpf content [Edited by - maxdub on April 22, 2008 7:02:37 PM]

Share this post


Link to post
Share on other sites
solved it on my own... you were close Mutex but you can't change a thread's concurrency model once its already been set and since i was trying to use the main thread, it wasn't working for me.

what i ended up doing was very close to what you were saying but i did it through managed code. I created a managed worker thread that ran on STA and then asked that thread to draw all the content.

more info:
http://msdn2.microsoft.com/en-us/library/system.threading.thread.aspx

Share this post


Link to post
Share on other sites
Doh, that was my initial response but I assumed you didn't want to create another managed thread given that your native app is calling managed code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this