I can't say I totally understand your question. But I've written controls that use Direct3D. Other than the fact that I'm not dealing with Device loss due to screensaver startup, it works great for me. Check out [1] for the code if you'd like to look at it.
Also, to answer the question I think you were asking about threads, no DirectX does not start any additional threads. Unless you do so yourself, as you appear to be doing in the code below. I can't say I understand why you're doing this, as having a lot of threads mucking around with UI elements is a recipe for disaster. But it could be I'm missing what you're after. > -----Original Message----- > From: Ben Kloosterman [mailto:[EMAIL PROTECTED]] > Sent: Saturday, January 18, 2003 1:24 AM > To: [EMAIL PROTECTED] > Subject: [ADVANCED-DOTNET] Controls / DirectX and threading > > > Ok I had a problem when using DirectX 9 to render to a > control that the form > ( actually a subform created from the mainform) would no > longer handle close > events, all other events were handled properly . Looking at > all the managed > DirectX samples they started the rendering loop from main() > which I suspect > is a different thread then the UI thread created by > Application.Run , this > is not really practical as the program I want to write is 90% > forms. as a > workaround solution starting the rendering as a new thread > seemed to work > fine. > > My question is whether this is save as the Rendering and > Application.DoEvents is done on a different thread from the UI. More > specifically does DirectX interfere with the UI thread and does > Application.DoEvents invoke the UI thread. > > Ben Kloosterman > > PS; code is below > > public virtual void Run() > { > try > { > if ( Init != null) > Init(this , new EventArgs()); > MethodInvoker mi = new MethodInvoker(mainloop); > mi.BeginInvoke(null , null ); > } > // catch > } > > private void mainloop() > { > System.Windows.Forms.Control mainWindow = this; > mainWindow.Show(); > while (mainWindow.Created) > { > Application.DoEvents(); > // TODO Get the app's time, in seconds. Skip rendering if > no time elapsed > if (Idle != null) > Idle(this , new EventArgs()); > Application.DoEvents(); > } // while > } > > You can read messages from the Advanced DOTNET archive, > unsubscribe from Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.
