[英]AppDomain.CurrentDomain.UnhandledException does not let me finish my function
Currently, I have a method that is called when there is an unhandled exception. 当前,我有一个未处理的异常时调用的方法。 All this does is log the exception to a dump file. 这一切都是将异常记录到转储文件中。 However, the streamwriter does not write the full information I'd like it to write to the file. 但是,streamwriter不会将我希望其写入的完整信息写入文件。 I assume this is because the program has shutdown before it can finish writing the file. 我认为这是因为程序在完成写入文件之前已关闭。
Is there any way to change this behaviour? 有什么办法可以改变这种行为?
在流Flush
上调用Flush
use 采用
using(var stream = new StreamWriter(@"C:\..."))
{
//logic
}
This will make sure, that stream will be closed and flushed in the finally
section. 这将确保在finally
部分中将关闭并刷新该流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.