Help Please. Error Closing multiple panels

sarky

New member
Joined
Jul 6, 2006
Messages
3
Programming Experience
3-5
I'm still fairly new at this so I appologise in advance if I've missed something simple.

Anyway.

I have a window with 2 panels. 2 of which are displaying seperate 3D scenes. When trying to exit the program I am endeavouring to close the panels to release the resources. But it errors with an access violation on whichever panel I try to close last.

Whichever I close first is no problem., nor is disposing of the device subsequently. But the last panel is a real problem.

I assume this is becaue it is the last and therefore the window no longer has any valid objects? Maybe?

But because I can't dispose of the panel I can't get rid of the device or close the window.

I know I can leave it cause I'm exiting, but it seems so sloppy. Anyone have any ideas?

Me.SuspendLayout()
' CRASHES Here? Why??? Obviously the device is in use somehow? or something is not finished. What?
' Whichever two lines go first work! The other group crashes.
Me.PanelView.Dispose()
theDevice.Dispose()
' These lines don't work when escape is pressed.
Me.PanelMap.Dispose()
theMapDevice.Dispose()
' Yet if i don't take dispose of all the panels and the devices I can't close and dispose of the window either.
Me.Close()
Me.Dispose()

end sub

Thanks in advance.

 
If you've created the Panels in the designer then you don't need to do anything. When the form is disposed it will dispose any and all objects that were created in the designer. You only have to worry about objects that you have created in code.
 
Still not working maybe I've done something fundamentally wrong :p

The panels were created in the designer.
But they are empty.

They are initialiesed with the Initialise component sub.

Later code then assigns a device to each panel, one for displaying my 3D scene and one for displaying a 3D map.

At the end if I try to close the devices it crashes on whichever is last.
If I just try to close the form it crashes on the close.
If I just try to dispose of the form it crashes on the dispose.
If I try to dispose of the panels it crashes on the last one to be disposed of, depends on which oreder i put them in.
If I try to dispose of the devices it crashes on the last one to be disposed of, depends on which order I put them in.

Just seems a bit wierd to me, can't think what I am missing.

Thanks for you reply though.
 
Error seems to relate to the devices actually.

After further investigation, it seems to be a device issue.

Basically by closing one of the devices corrupts the other preventing it from closing. Which knocks on to other areas..

Any ideas why two seperate devices could do this?

One is assigned to one panel, the second to a different panel. Bothe are hardware run, managed 3d devices.

theDevice = New Device(0, DeviceType.Hardware, Me.PanelView, CreateFlags.HardwareVertexProcessing Or CreateFlags.FpuPreserve, presentParams)

theMapDevice =
New Device(0, DeviceType.Hardware, Me.PanelMap, CreateFlags.HardwareVertexProcessing Or CreateFlags.FpuPreserve, presentParams)

Whichever I dispose of first corrupts the other so I can't dispose of it. If I put an error trap around the second device dispose and ignore the error the program closes fine. Any ideas what I should look for?

Thanks

 
Back
Top