How to track when my application has unexpectedly shut down?
Posted
by Vilx-
on Stack Overflow
See other posts from Stack Overflow
or by Vilx-
Published on 2010-04-20T12:17:28Z
Indexed on
2010/04/20
12:23 UTC
Read the original article
Hit count: 141
I'm writing an application whose purpose involves a lot of logging of different events. Among those I would also like to have an event that the application was shut down - even if unexpectedly like because of a power loss.
Naturally, when the power goes out I don't get a chance to write anything anywhere. So my idea was to continuously write a timestamp in some known location (say, once per minute), and when the application was next run, it could determine the approximate time of the unexpected shutdown. A precision of 1 minute would be acceptable for me.
However I'm worried that caching at the OS and disk level might interfere with this approach. Is there a better way or if not - how to make sure that the data I just wrote is REALLY written out to the physical medium?
Added: Oh, almost forgot the buzzword line: Windows XP and above; .NET 3.5; C#.
© Stack Overflow or respective owner