多线程应用程序中的错误记录 [英] Error Logging in Multi Thread App

查看:64
本文介绍了多线程应用程序中的错误记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在编写的使用多线程的C#WPF应用程序.推荐的记录错误的方法是什么?您是否将每个线程报告的错误都返回到主表单进行处理?还是让每个线程将错误记录到数据库或文件本身?我只是在寻找一点见识,而在其他地方找不到太多关于该主题的信息.

谢谢,
Scott

I have a C# WPF application that I am writing that uses multithreading. What is the recommended method for logging errors? Do you have each thread report errors back to the main form for processing? Or have each thread log the errors to the DB or file itself? I am just looking for a little insight and couldn''t find much on the subject elsewhere.

Thanks,
Scott

推荐答案

我只是将其记录在应用程序日志中(Windows的一部分).如果您采取措施在线程本身中提供标识功能,则该线程可以标识该线程,以便该线程在创建日志条目时可以标识自己.
I would just log it in the application log (part of Windows). You can identify the thread if you take steps to provide identification functionality in the thread itself so that the thread can identify itself when it makes the log entry.


如果您喜欢日志文件,则可以创建一个流,并使用互斥保护它.至少这是我在Linux下执行的方式.
If you like log file you can create one stream and protect it with mutex. At least that is the way I do it under Linux.


这篇关于多线程应用程序中的错误记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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