using System;
using System.Diagnostics;
using Avalonia.Interactivity;
namespace Avalonia.Threading;
///
/// Represents the method that will handle the event.
///
public delegate void DispatcherUnhandledExceptionEventHandler(object sender, DispatcherUnhandledExceptionEventArgs e);
///
/// Provides data for the event.
///
public sealed class DispatcherUnhandledExceptionEventArgs : DispatcherEventArgs
{
private Exception _exception;
private bool _handled;
internal DispatcherUnhandledExceptionEventArgs(Dispatcher dispatcher) : base(dispatcher)
{
_exception = null!;
}
///
/// Gets the exception that was raised when executing code by way of the dispatcher.
///
public Exception Exception => _exception;
///
/// Gets or sets whether the exception event has been handled.
///
public bool Handled
{
get
{
return _handled;
}
set
{
// Only allow to be set true.
if (value)
{
_handled = value;
}
}
}
internal void Initialize(Exception exception, bool handled)
{
Debug.Assert(exception != null);
_exception = exception;
_handled = handled;
}
}