开发者

C# - Debug.WriteLine - is this function ASync?

开发者 https://www.devze.com 2022-12-20 08:37 出处:网络
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

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.

I开发者_JS百科s Debug.WriteLine Async or data has been stacked in Visual Studio's buffer and is getting displayed slowly?


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.


Visual Studio is doing the async part. The Win32 API OutputDebugString does the same thing in Visual Studio's output window.

You could try using DebugView instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号