Reputation: 2731
I have a pretty normal WPF program (in VB.net but same should be no different to C#) and have implemented the TextWriterTraceListener which writes everything to a log file. The issue I have is that if there is an exception that is uncaught then my app crashes and the log file seems to be "behind" so it does not show the very last entry before crashing.
Can I somehow make the TextWriterTraceListener write to the log file faster?
I have implemented the Application_DispatcherUnhandledException but this does not seem to catch my unhandled errors.
I am aware that on a proper close down I have to call flush and close on the TextWriterTraceListener object, the issue is that if my app crashes I don't get the opportunity to do this.
Upvotes: 0
Views: 525
Reputation: 1582
Have you tried to add
AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
As well as your Application_DispatcherUnhandledException
?
Upvotes: 2