private void OnContextMenuDisposed(object sender, EventArgs e)
{
// Should still be caching a reference to actual display control
if (_contextMenu != null)
{
// Unhook from control, so it can be garbage collected
_contextMenu.Disposed -= new EventHandler(OnContextMenuDisposed);
// Copy to ourself the close reason
if (_contextMenu.CloseReason.HasValue)
CloseReason = _contextMenu.CloseReason.Value;
// No longer need to cache reference
_contextMenu = null;
// Notify event handlers the context menu has been closed and why it closed
OnClosed(new ToolStripDropDownClosedEventArgs(CloseReason));
}
}