mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
[PTRun] Gracefully shutdown all threads when exiting (#20450)
This commit is contained in:
@@ -20,6 +20,7 @@ using PowerLauncher.Plugin;
|
||||
using PowerLauncher.Telemetry.Events;
|
||||
using PowerLauncher.ViewModel;
|
||||
using Wox.Infrastructure.UserSettings;
|
||||
using CancellationToken = System.Threading.CancellationToken;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using Log = Wox.Plugin.Logger.Log;
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
@@ -30,6 +31,7 @@ namespace PowerLauncher
|
||||
{
|
||||
private readonly PowerToysRunSettings _settings;
|
||||
private readonly MainViewModel _viewModel;
|
||||
private readonly CancellationToken _nativeWaiterCancelToken;
|
||||
private bool _isTextSetProgrammatically;
|
||||
private bool _deletePressed;
|
||||
private HwndSource _hwndSource;
|
||||
@@ -38,18 +40,19 @@ namespace PowerLauncher
|
||||
private bool _disposedValue;
|
||||
private IDisposable _reactiveSubscription;
|
||||
|
||||
public MainWindow(PowerToysRunSettings settings, MainViewModel mainVM)
|
||||
public MainWindow(PowerToysRunSettings settings, MainViewModel mainVM, CancellationToken nativeWaiterCancelToken)
|
||||
: this()
|
||||
{
|
||||
DataContext = mainVM;
|
||||
_viewModel = mainVM;
|
||||
_nativeWaiterCancelToken = nativeWaiterCancelToken;
|
||||
_settings = settings;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
_firstDeleteTimer.Elapsed += CheckForFirstDelete;
|
||||
_firstDeleteTimer.Interval = 1000;
|
||||
NativeEventWaiter.WaitForEventLoop(Constants.RunSendSettingsTelemetryEvent(), SendSettingsTelemetry);
|
||||
NativeEventWaiter.WaitForEventLoop(Constants.RunSendSettingsTelemetryEvent(), SendSettingsTelemetry, _nativeWaiterCancelToken);
|
||||
}
|
||||
|
||||
private void SendSettingsTelemetry()
|
||||
|
||||
Reference in New Issue
Block a user