• Advertisement
Sign in to follow this  

[.net] Threading a MDX User Control

This topic is 4617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've written a MDX User Control that I've contained inside a Windows Form. I also have a series of buttons inside the form that i want to pass off rotation data to the MDX User Control. This works fine, but I also want to use a Timer in the main form which won't fire it's Tick event due to the constant drawing in the OnPaint method of the UserControl. How can I get this control to paint in a seperate thread? I've tried doing all of the device initialization in a thread but when i do that nothing shows up on the form, eventhough i can still call my methods on the control.

Share this post


Link to post
Share on other sites
Advertisement
Look into the Invoke method of the form. If you're in another thread and you need to run a function in the form's thread, you must invoke it. This can also be done asynchronously with BeingInvoke and EndInvoke.

Share this post


Link to post
Share on other sites
What I do to get around this is to initialize my d3d device in the main thread and then pass the device reference to the child thread. The child thread can then do everything just fine, such as creating new textures/vb's and even calling device.Present() and it co-operates with the main thread great. I have a timer on my main thread to calculate the FPS and it works great, so this should hopefully solve your problem.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement