Trace.Flush()-数据会立即写入TextWriterTraceListener吗? [英] Trace.Flush() - Will data get written to TextWriterTraceListener immediately?

查看:31
本文介绍了Trace.Flush()-数据会立即写入TextWriterTraceListener吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果使用自动刷新,或在每次写入消息时手动刷新,则在Visual Studio中进行调试时,我会注意到一些问题,即使启用AutoFlush = true,也看不到写入文件的数据.仅当我停止调试器时,文件才会更新.这使我相信,仅在特定时间或程序完成时才刷新数据.

If using auto flush, or flushing manually on each write of message, I noticed something while debugging in Visual studio, I don't see the data written to file even though I enable AutoFlush = true. The file only gets updated when I stop the debugger. This led me to believe that the data is only being flushed at certain time, or when the program comes to completion.

这是调试的副作用吗?在实际程序中,它的行为会有所不同吗?

Or is this a side effect of debugging and in the actual program it will behave differently?

什么时候写入数据?立即,在发生某些事件或时间之后?

At what point will data get written? Right away, or after some event, or time?

我确实在Visual Studio的调试输出"窗口中看到了输出消息,只是没有在文件中看到.

I do see the output message in the Debug Output windows of Visual Studio, just not in the file.

推荐答案

我想我在这里找到了解释即使跟踪事件被调用,跟踪文件也不会被创建?

I think I found an explanation here Trace file isn't being created even though TraceEvent is called?

当内部缓冲区填满时,写入器将刷新到磁盘,如果内存为我提供服务,则默认缓冲区大小为8KB.这不是跟踪侦听器的方面,而是写入的基本文件流."

"Writers flush to disk when their internal buffers fill, if memory serves me the default buffer size is 8KB. This is not a facet of trace listeners, but the underlying file stream it writes to."

这篇关于Trace.Flush()-数据会立即写入TextWriterTraceListener吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆