C# - Debug.WriteLine - 这个函数是异步的吗? [英] C# - Debug.WriteLine - is this function ASync?

查看:29
本文介绍了C# - Debug.WriteLine - 这个函数是异步的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚遇到了一个情况:我正在调试一个遍历大量数据的线程.我正在使用 Debug.WriteLine 打印正在处理的记录.刚刚发生的事情是线程报告它已经处理了所有记录,但是,Visual Studio 的调试窗口仍然显示出来.我确信线程已经完成了它的工作.

I just came across a situation: I was debugging a thread which iterates through a large amount of data. I was using Debug.WriteLine to print which record is being processed. What just happened is that thread has reported that it has processed all records, however, Visual Studio's debug window is still displaying out. I am positive that thread has completed its job.

Debug.WriteLine 是否为异步或数据已堆积在 Visual Studio 的缓冲区中并且显示缓慢?

Is Debug.WriteLine Async or data has been stacked in Visual Studio's buffer and is getting displayed slowly?

推荐答案

MS 没有提到这个方法是异步的.Debug.WriteLine 方法对跟踪侦听器进行操作,您看到的现象是跟踪侦听器而非 Debug.WriteLine 实现的结果.

MS does not mention this method as being async. The Debug.WriteLine method operates on the trace listeners and the phenomena you are seeing is a result of the implementation of the trace listener and not the Debug.WriteLine.

通常,当缓冲区已满或超时后,输出会刷新到屏幕上,而不是在发生时刷新.这意味着您应该期望输出同步但延迟.

In general output is flushed to the screen when a buffer is full or after a timeout and not as it happens. This means that you should expect the output to be synchronous but delayed.

这篇关于C# - Debug.WriteLine - 这个函数是异步的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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