Skip to content

Commit 797e36e

Browse files
committed
Improve TrayManu.Dispose() method implementation #293
1 parent d9307ba commit 797e36e

File tree

1 file changed

+21
-9
lines changed
  • Source/Office/Tools/Contribution/TrayMenuUtils

1 file changed

+21
-9
lines changed

Source/Office/Tools/Contribution/TrayMenuUtils/TrayMenu.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -875,24 +875,36 @@ private ToolStripItem Find(TrayMenuItem item, ToolStripItemCollection items)
875875
#region IDisposableState
876876

877877
/// <summary>
878-
/// Returns information the instance is already disposed
878+
/// Gets a value indicating whether the control has been disposed of.
879879
/// </summary>
880880
public bool IsDisposed { get; private set; }
881881

882882
/// <summary>
883-
/// Dispose the instance
883+
/// Dispose the instance.
884884
/// </summary>
885885
public void Dispose()
886886
{
887-
if (IsDisposed)
887+
this.Dispose(true);
888+
}
889+
890+
/// <summary>
891+
/// Dispose the instance.
892+
/// </summary>
893+
/// <param name="disposing"></param>
894+
protected virtual void Dispose(bool disposing)
895+
{
896+
if (this.IsDisposed)
888897
{
889-
if (null != _contextMenu)
890-
{
891-
_contextMenu.Dispose();
892-
_contextMenu = null;
893-
}
894-
IsDisposed = true;
898+
return;
895899
}
900+
901+
if (disposing)
902+
{
903+
_contextMenu?.Dispose();
904+
_contextMenu = null;
905+
}
906+
907+
this.IsDisposed = true;
896908
}
897909

898910
#endregion

0 commit comments

Comments
 (0)