Winify

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 76  →  ?path2? @ 77
/trunk/Winify/MainForm.cs
@@ -9,6 +9,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using NetSparkleUpdater;
using NetSparkleUpdater.Enums;
using NetSparkleUpdater.SignatureVerifiers;
@@ -64,6 +65,8 @@
{
InitializeComponent();
 
SystemEvents.PowerModeChanged += OnPowerModeChanged;
 
_cancellationTokenSource = new CancellationTokenSource();
_cancellationToken = _cancellationTokenSource.Token;
 
@@ -111,6 +114,31 @@
 
#region Event Handlers
 
private async void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
switch (e.Mode)
{
case PowerModes.Resume:
// Refresh connection to gotify server.
while (_gotifyConnections.TryTake(out var gotifyConnection))
{
gotifyConnection.GotifyMessage -= GotifyConnectionGotifyMessage;
await gotifyConnection.Stop();
gotifyConnection.Dispose();
}
 
var servers = await LoadServers();
foreach (var server in servers.Server)
{
var gotifyConnection = new GotifyConnection(server, Configuration);
gotifyConnection.GotifyMessage += GotifyConnectionGotifyMessage;
gotifyConnection.Start();
_gotifyConnections.Add(gotifyConnection);
}
break;
}
}
 
private async void MainForm_Load(object sender, EventArgs e)
{
Configuration = await LoadConfiguration();