Skip to content

Instantly share code, notes, and snippets.

@heltonbiker
Created July 6, 2018 14:06
Show Gist options
  • Save heltonbiker/6da5beba34bbcc18a2235195e6e50fd1 to your computer and use it in GitHub Desktop.
Save heltonbiker/6da5beba34bbcc18a2235195e6e50fd1 to your computer and use it in GitHub Desktop.
Tratamento Global de Exceção
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