public class ApplicationClosingService : CloseApplicationWatcherBase, IApplicationClosingService
{
public bool IsClosing { get; private set; }
public event AsyncEventHandler<EventArgs> ApplicationClosingAsync;
public event EventHandler<EventArgs> ApplicationClosingCanceled;
protected override async Task<bool> ClosingAsync()
{
IsClosing = true;
await ApplicationClosingAsync.SafeInvokeAsync(this, EventArgs.Empty);
return await base.ClosingAsync();
}
protected override void ClosingCanceled()
{
IsClosing = false;
ApplicationClosingCanceled?.Invoke(this, EventArgs.Empty);
base.ClosingCanceled();
}
}