Skip to content

Commit

Permalink
wrapping agressively the timer. (#5560)
Browse files Browse the repository at this point in the history
Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
  • Loading branch information
2 people authored and enricogior committed Aug 4, 2020
1 parent 797bedd commit d323611
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
using System;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using PowerLauncher.Helper;
using PowerLauncher.ViewModel;
using System;
using System.ComponentModel;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using PowerLauncher.Helper;
using Wox.Infrastructure.UserSettings;
using PowerLauncher.ViewModel;

using Screen = System.Windows.Forms.Screen;
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
using System.Windows.Controls;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Timers;
using Microsoft.PowerLauncher.Telemetry;
using Microsoft.PowerToys.Telemetry;
using Screen = System.Windows.Forms.Screen;


namespace PowerLauncher
Expand Down Expand Up @@ -47,10 +43,13 @@ public MainWindow(Settings settings, MainViewModel mainVM) : this()

private void CheckForFirstDelete(object sender, ElapsedEventArgs e)
{
_firstDeleteTimer.Stop();
if (_deletePressed)
if (_firstDeleteTimer != null)
{
PowerToysTelemetry.Log.WriteEvent(new LauncherFirstDeleteEvent());
_firstDeleteTimer.Stop();
if (_deletePressed)
{
PowerToysTelemetry.Log.WriteEvent(new LauncherFirstDeleteEvent());
}
}

}
Expand Down Expand Up @@ -350,7 +349,10 @@ private void OnVisibilityChanged(object sender, DependencyPropertyChangedEventAr
if (Visibility == Visibility.Visible)
{
_deletePressed = false;
_firstDeleteTimer.Start();
if (_firstDeleteTimer != null)
{
_firstDeleteTimer.Start();
}
// (this.FindResource("IntroStoryboard") as Storyboard).Begin();

SearchBox.QueryTextBox.Focus();
Expand All @@ -376,7 +378,10 @@ private void OnVisibilityChanged(object sender, DependencyPropertyChangedEventAr
}
else
{
_firstDeleteTimer.Stop();
if (_firstDeleteTimer != null)
{
_firstDeleteTimer.Stop();
}
}
}

Expand All @@ -402,11 +407,15 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_firstDeleteTimer.Dispose();
if (_firstDeleteTimer != null)
{
_firstDeleteTimer.Dispose();
}
}

// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
_firstDeleteTimer = null;
disposedValue = true;
}
}
Expand Down

0 comments on commit d323611

Please sign in to comment.