mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #561 from taooceros/CloseWithDispose
Dispose Disposable or AsyncDisposable plugin on mainwindow close
This commit is contained in:
commit
55e985faae
2 changed files with 21 additions and 1 deletions
|
|
@ -58,6 +58,22 @@ namespace Flow.Launcher.Core.Plugin
|
|||
API.SavePluginSettings();
|
||||
}
|
||||
|
||||
public static async ValueTask DisposePluginsAsync()
|
||||
{
|
||||
foreach (var pluginPair in AllPlugins)
|
||||
{
|
||||
switch (pluginPair.Plugin)
|
||||
{
|
||||
case IDisposable disposable:
|
||||
disposable.Dispose();
|
||||
break;
|
||||
case IAsyncDisposable asyncDisposable:
|
||||
await asyncDisposable.DisposeAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task ReloadData()
|
||||
{
|
||||
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using Flow.Launcher.Core.Resource;
|
|||
using Flow.Launcher.Helper;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using Application = System.Windows.Application;
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
||||
using DataFormats = System.Windows.DataFormats;
|
||||
|
|
@ -46,10 +47,13 @@ namespace Flow.Launcher
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnClosing(object sender, CancelEventArgs e)
|
||||
private async void OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
_notifyIcon.Visible = false;
|
||||
_viewModel.Save();
|
||||
e.Cancel = true;
|
||||
await PluginManager.DisposePluginsAsync();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void OnInitialized(object sender, EventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in a new issue