![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 211
Rep Power: 3
![]() |
.NET Timer Form closing issue
This question pertains specifically to the .NET Compact framework version 1.1.
The problem is using Timers with the Form.ShowDialog() and Form.Close() command. When a timer is created on a form with the Form.Show() command it is attached to the form, so that the form will stop and (supposedly) close the timer when the form is destroyed, however with the ShowDialog command is used. However when using the ShowDialog command the timer is attached differently to the form so that it can keep running after the form has been closed, and in some cases even destroyed. (note: We can't use Show instead of ShowDialog() for various other reasons, notably our dynamic creations of forms from a database tends to issues with Form.Show()) This causes two problems. First we'll occasionally have a timer run, that because the form underneath it has been destroyed, that will cause various unhandled null reference exceptions and the like. Secondly : Even if the timer is not running, it appears that it is never getting destroyed, since that is normally handled in the form destruction code. (Or the code will keep running, without causing an exception) causing a small possibly undetectable memory leak. (This code is designed to run for months if not years at a time, a small memory leak can be substancial, we've ran tests of several weeks at a time without problem, but a leak this small we might not be able to detect over such a small period of time) Is there a way to force the timers destruction with the destruction or closing of the form? Additionally is there a way to automate this process to prevent from having to individually evaluate each form. Thanks, -MBirchmeier |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|