index > Visual C# General > Resetting d3device error

Resetting d3device error

Is there any procedure before and after resetting the directX device ?
I want to make the toggle fullscreen function , but when I restart the device , there are errors (sometime the error is unknown , sometime it throws DeviceLost Exception).
I can start the directX device at the beginning , but if i change the presentationParams and reset the device , it occur error. My code is like this :

void initdevice(bool fullscreen) {
 PresentParameters d3dpp = new PresentParameters();
 d3dpp.DeviceWindow = form1;
 d3dpp.BackBufferWidth = 800;
 d3dpp.BackBufferHeight = 600;
 if (fullscreen) {
  d3dpp.Windowed = false;
 } else {
  form1.ClientSize = new Size(800, 600);
  d3dpp.Windowed = true;
 }

 if (device != null) {
  device.Reset(d3dpp);
 } else {
  device = new Device(Manager.Adapters[0].Adapter, DeviceType.Hardware, form1, CreateFlags.HardwareVertexProcessing, d3dpp);
 }
}

Is there any procedure that I missed ? or the window form's problem ? or reset method is wrong ?
I see some of the programmer simply dispose old device and create a new device instead of using reset(d3dpp) , which method is better ?

Also I've a question about threading.
If a thread is suspended, and the program is going to be disposed. How to terminate the suspended thread ?
When I try to use thread.Abort() to terminate it , it seems no effect ( I see it still 'isAlive' in the watch ) .
If I first resume the thread then abort it , it seems a fool method , and it may not work all the time.
I use another thread to do rendering. So sometimes if the render is suspended, and to program is going to be disposed , it crush (maybe the D3Device is disposed , but the render thread fail to terminate.)

Sces
Sces -
Similar to the response to your last post, you should try the managed Directx newsgroup -- they probably have more expertise in this area.

Thanks,
Karen Liu
Visual C#


Program Manager, Visual C#
Karen Liu MSFT
I have a full list of forums for Managed DirectX including the newsgroups here

http://www.thezbuffer.com/categories/forums.aspx



http://www.thezbuffer.com - News & Resources for Managed DirectX and XNA Framework
TheZbuffer
reply 3

You can use google to search for other answers

 

More Articles

• close app that is running in the background
• windows forms getting controls
• what is wrong with MDI ChildForm Menu
• Synchronous versus Asynchronous
• Index out of range - seraching Active Directory
• Whither encapsulte field in Express beta2?
• OLE Objects
• Stuck on ShowDialog
• Controling windows Volume
• Want to find some good books
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Linkbuttons not working in Asynchronous
• Help with UI not updating
• How to display totals
• VScroll Code Problem , Please Help
• UserControl Terminate or Close Event
• ALT+F4 question
• ERROR [07002] [Microsoft][ODBC Microsoft
• datareader?
• Using a variable to select an array
• using System.Drawing namespace in a Clas
• IIS Web Control Panel
• Forms conversion guide
• .cs file in deployment
• Creating CAB Files programmatically
• Problem in accesssing System.IO.Compress

Hot Articles

• Perfmon stopped working under Windows XP
• problem with datagridview saving event
• foreach over an array, can I specify a p
• Print to a File in the server
• Switching off computer using C#
• Using C dll (and running on another mach
• Need good tutorial for Query Builder
• pleas: how i can read image, to get the
• Problem with keybd_event()
• Reinstall creates multiple entries in Ad
• DirectX and Visual C# Express???
• serialport- stopbits.none error
• namespace for ConfigurationManager
• How I can fill a DataTable with a DataGr
• How to get return code from a launched p

Recommend Articles

• tabpage disable
• get ValueMember and DisplayMember from d
• the dismatching error with "unsafe&
• Unable to run application on different m
• Default Text property in User Control
• button_click method
• DataGrid multiple controls??????
• File Upload in asp.net
• Adding licensing capability to my app
• How to display totals
• get user directory
• How to set a ConnectionString Setting at
• NotifyIcon balloon does not work if appl
• Create updates of my Setup project?
• Executing sql command in C# problem stri