I am writing an ASCOM telescope driver and I need to guarantee that a few serial port commands are sent to the scope to stop the scope from moving when an client application fails to disconnect properly or crashes.
I tried adding a finalizer that looks something like this
~Telescope()
{
Common.AbortSlew();
Common.SetTracking(false);
}
it makes it to the SendSerialPortCommand() method and then quits without actually sending the bytes out on the wire and seems to quit just before a lock statement.
repo can be viewed here
http://code.google.com/p/ascom-nexstar-telescope/source/browse/NexStar/
finalizer is in driver.cs called methods are in static class Common
is there a better or more reliable way to accomplish this?