mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Remotely.Desktop.Core;
|
|
using Remotely.Desktop.Core.Interfaces;
|
|
using Remotely.Desktop.Core.Services;
|
|
using Remotely.Shared.Utilities;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace Remotely.Desktop.Win.Services
|
|
{
|
|
public class ShutdownServiceWin : IShutdownService
|
|
{
|
|
public async Task Shutdown()
|
|
{
|
|
try
|
|
{
|
|
Logger.Write($"Exiting process ID {Process.GetCurrentProcess().Id}.");
|
|
var casterSocket = ServiceContainer.Instance.GetRequiredService<ICasterSocket>();
|
|
await casterSocket.DisconnectAllViewers();
|
|
await casterSocket.Disconnect();
|
|
System.Windows.Forms.Application.Exit();
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
App.Current.Shutdown();
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Write(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|