[.net] Running DirectX in a seperate thread in VB.net

Started by
23 comments, last by Ixusv4 16 years, 2 months ago
I can do DirectX in an picturebox on a form in VB.net.. Only problem is when I put a slider or anything else on the form for example adjust the speed of something..the rendering halts..Is there a way to run DirectX in a seperate thread so that the rendering loop will continu when I do something else on a form?
Advertisement
You don't need to run directx in a different thread to do this. How are you handling the forms events, and when is the rendering occurring?

For that matter, I'm not sure directx would even appreciate being in a different thread from the form it's being rendered to.
The rendering is currently done in a class. In the future I would like to make a DLL with these classes. The rendering is done in loop wich fires every 40 miliseconds...

The program on this stage is an MDI with a form wich shows the actual render...Another form is a control form with several sliders on it to control the movement of the object..Once I slide a slider...the rendering is halted...

Are there any examples wich can help me with the current problem..
I don't have any specific examples, but I've done it before.

Instead of handing event handling over to application.run, and doing the rendering on a timed basis, use application.doevents instead.

Something like the following (c#, but you get the idea):

while(someForm.Created)
{
// Render to picture box
Application.DoEvents();
}
I have the Doevents in my renderloop....buth that doesn't solve the issue...too bad :(
I'm confused. Rendering halts when you add the scrollbar/objects or when the user interects with the scrollbar/object?

If it's interaction, then yes running it on another thread will solve the problem. But before I gurantee that 100%, answer the above question ;)
Quote:Original post by gharen2
I don't have any specific examples, but I've done it before.

Instead of handing event handling over to application.run, and doing the rendering on a timed basis, use application.doevents instead.

Something like the following (c#, but you get the idea):

while(someForm.Created)
{
// Render to picture box
Application.DoEvents();
}

Bad Code!

Better code! [grin]

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Yeah yeah yeah.

I didn't want to complicate things further by going into that. I figure, once he gets it working with Application.DoEvents, he can look at optimizing it. Implement first, optimize second, they always say :)
The DOEvents was already implanted in my renderloop. If it wasn't there any interaction with other controls on any form in the same program would be impossible.

The problem arises when the user interacts with the scrollbar/object or any object or when one moves any form around..

The problem is in the fact dat VB.net is not multi-tasking. And usually one makes a directX program Fullscreen...Buth I want to make my own 3D Editor :(
Quote:Original post by gharen2
Yeah yeah yeah.

I didn't want to complicate things further by going into that. I figure, once he gets it working with Application.DoEvents, he can look at optimizing it. Implement first, optimize second, they always say :)


Yeah, but implement the best way you know how. :)

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

This topic is closed to new replies.

Advertisement