Created
July 6, 2018 14:06
-
-
Save heltonbiker/6da5beba34bbcc18a2235195e6e50fd1 to your computer and use it in GitHub Desktop.
Tratamento Global de Exceção
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows; | |
using System.Windows.Threading; | |
namespace TratamentoGlobalExcecao | |
{ | |
public partial class App : Application | |
{ | |
[STAThread] | |
static void Main(string[] args) | |
{ | |
AppDomain.CurrentDomain.UnhandledException += | |
CurrentDomain_UnhandledException; | |
var app = new App(); | |
app.InitializeComponent(); | |
app.Run(new MainWindow()); | |
} | |
static App() | |
{ | |
// Fazer alguma coisa aqui? | |
} | |
public App() | |
{ | |
DispatcherUnhandledException += | |
App_DispatcherUnhandledException; | |
} | |
protected override void OnStartup(StartupEventArgs e) | |
{ | |
base.OnStartup(e); | |
// Assinar algum evento aqui? | |
} | |
// EXCEPTION HANDLERS | |
static void CurrentDomain_UnhandledException( | |
object sender, UnhandledExceptionEventArgs e) | |
{ | |
// Logar o que? | |
// Fazer mais o que? | |
} | |
void App_DispatcherUnhandledException( | |
object sender, DispatcherUnhandledExceptionEventArgs e) | |
{ | |
// Logar o que? | |
// Fazer mais o que? | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment