Refactor TryDisposeAll

This commit is contained in:
Jared Goodwin 2021-04-25 17:32:07 -07:00
parent 5fa05fa0d1
commit d7012b068f
4 changed files with 4 additions and 19 deletions

View File

@ -87,11 +87,7 @@ namespace Remotely.Desktop.Core.Services
public void Dispose()
{
DisconnectRequested = true;
Disposer.TryDisposeAll(new IDisposable[]
{
RtcSession,
Capturer
});
Disposer.TryDisposeAll(RtcSession, Capturer);
GC.SuppressFinalize(this);
}

View File

@ -61,12 +61,7 @@ namespace Remotely.Desktop.Core.Services
}
catch { }
PeerSession.Transceivers.RemoveAll(x => true);
Disposer.TryDisposeAll(new IDisposable[]
{
Transceiver?.LocalVideoTrack,
VideoSource,
PeerSession
});
Disposer.TryDisposeAll(Transceiver?.LocalVideoTrack, VideoSource, PeerSession);
GC.SuppressFinalize(this);
}

View File

@ -25,13 +25,7 @@ namespace Remotely.Desktop.Win.Models
public void Dispose()
{
Disposer.TryDisposeAll(new IDisposable[]
{
Adapter,
Device,
OutputDuplication,
Texture2D
});
Disposer.TryDisposeAll(Adapter, Device, OutputDuplication, Texture2D);
GC.SuppressFinalize(this);
}
}

View File

@ -4,7 +4,7 @@ namespace Remotely.Shared.Utilities
{
public static class Disposer
{
public static void TryDisposeAll(IDisposable[] disposables)
public static void TryDisposeAll(params IDisposable[] disposables)
{
if (disposables is null)
{