Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
85133af5
Commit
85133af5
authored
Nov 10, 2021
by
段廷瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、增加未处理异常监控
parent
6fc6ee7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
Utils.cs
Tools/MyUtils/Utils.cs
+11
-0
Program.cs
Tools/Program.cs
+15
-0
No files found.
Tools/MyUtils/Utils.cs
View file @
85133af5
...
...
@@ -282,6 +282,17 @@ namespace Tools.MyUtils
var
result
=
MessageBox
.
Show
(
msg
,
"提示"
,
MessageBoxButtons
.
YesNo
,
MessageBoxIcon
.
Question
);
return
result
==
DialogResult
.
Yes
;
}
/// <summary>
/// 异常提示
/// </summary>
/// <param name="e"></param>
public
static
void
TipException
(
Exception
e
)
{
if
(
e
!=
null
)
{
Tip
(
$"错误消息:
{
e
.
Message
}
\r\n调用堆栈:\r\n
{
e
.
StackTrace
}
"
,
600
,
400
);
}
}
/// <summary>
/// 显示帮助信息
...
...
Tools/Program.cs
View file @
85133af5
...
...
@@ -5,6 +5,8 @@ using System.IO;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
//
using
Tools.MyUtils
;
namespace
Tools
{
...
...
@@ -16,10 +18,23 @@ namespace Tools
[
STAThread
]
static
void
Main
()
{
Application
.
ThreadException
+=
Application_ThreadException
;
AppDomain
.
CurrentDomain
.
UnhandledException
+=
CurrentDomain_UnhandledException
;
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
wMain
());
}
//UI未处理异常
private
static
void
Application_ThreadException
(
object
sender
,
System
.
Threading
.
ThreadExceptionEventArgs
e
)
{
Utils
.
TipException
(
e
.
Exception
);
}
//非UI未处理异常
private
static
void
CurrentDomain_UnhandledException
(
object
sender
,
UnhandledExceptionEventArgs
e
)
{
Utils
.
TipException
(
e
.
ExceptionObject
as
Exception
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment