This is related to issue #1130. If main window is visible and OnClosing sets e.Cancel = true to prevent closing, an exception is thrown for this sequence:
try to close window (click on red X), window does not close. Ok.
try to close app on context menu, app does not close. Ok.
try to close window (click on red X), exception. Not ok.
Expected Behavior
No exception.
Actual Behavior
Exception after above sequence.
Code that Demonstrates the Problem
using Eto.Forms;
using Eto.Drawing;
namespace EtoTrayApp
{
using System.ComponentModel;
public partial class MainForm : Form
{
private TrayIndicator _tray;
public MainForm()
{
Title = "My Eto Form";
ClientSize = new Size(200, 200);
_tray = new TrayIndicator
{
Image = Eto.Drawing.Icon.FromResource("EtoTrayApp.error.ico"),
Menu = new ContextMenu
{
Items =
{
new ButtonMenuItem {Text = "Quit", Command = new Command((s, e) => Application.Instance.Quit())}
}
}
};
ShowInTaskbar = false;
_tray.Visible = true;
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
e.Cancel = true;
}
}
}
This is related to issue #1130. If main window is visible and OnClosing sets e.Cancel = true to prevent closing, an exception is thrown for this sequence:
Expected Behavior
No exception.
Actual Behavior
Exception after above sequence.
Code that Demonstrates the Problem
Specifications