Skip to content

Commit

Permalink
Merge pull request #52 from mpolicki/VirtualDesktop/add-Dispose
Browse files Browse the repository at this point in the history
Add IDisposable implementation
  • Loading branch information
Grabacr07 authored Aug 27, 2020
2 parents b877ece + c9e0c61 commit f6f7458
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion source/VirtualDesktop/VirtualDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace WindowsDesktop
[ComInterfaceWrapper]
[DebuggerDisplay("{Id}")]
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
public partial class VirtualDesktop : ComInterfaceWrapperBase
public partial class VirtualDesktop : ComInterfaceWrapperBase, IDisposable
{
/// <summary>
/// Gets the unique identifier for this virtual desktop.
Expand Down Expand Up @@ -86,5 +86,35 @@ public VirtualDesktop GetRight()
return null;
}
}

#region IDisposable
private bool _disposed = false;

/// <summary>
/// Disposes of this <see cref="VirtualDesktop"/>.
/// </summary>
/// <param name="disposeOfManagedObjects">If <see langword="true"/>, disposes of managed objects.</param>
protected virtual void Dispose(bool disposeOfManagedObjects)
{
if (!this._disposed)
{
if (disposeOfManagedObjects)
{
this.Remove();
}

this._disposed = true;
}
}

/// <summary>
/// Disposes of this <see cref="VirtualDesktop"/>.
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}

0 comments on commit f6f7458

Please sign in to comment.