コード例 #1
0
 public MainForm()
 {
     InitializeComponent();
     _logManager = CustomLogManager.GetInstance();
     ((CustomLogManager)_logManager).LogChangedEvent += MainForm_LogChangedEvent;
     StartCollectService();
 }
コード例 #2
0
 private void StartCollectService()
 {
     if (_process != null)
     {
         MessageBox.Show("服务已启动");
     }
     else
     {
         _process = new ActiveProccess(CustomLogManager.GetInstance());
         _process.Run(Address, Port);
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: baominxing/Learning
 private static void Main()
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + "开始运行程序" + "\r\n");
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         //处理未捕获的异常
         Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
         //处理UI线程异常
         Application.ThreadException += Application_ThreadException;
         //处理非UI线程异常
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
         //运行主程序
         Application.Run(new MainForm());
     }
     catch (Exception e)
     {
         CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.Message + "\r\n");
     }
 }
コード例 #4
0
 public static CustomLogManager GetInstance()
 {
     return(_instance ?? (_instance = new CustomLogManager()));
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: baominxing/Learning
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.Exception + "\r\n");
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: baominxing/Learning
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.ExceptionObject + "\r\n");
 }