mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Using new thread to check upgrade
This commit is contained in:
@@ -8,13 +8,13 @@ using Wox.Infrastructure;
|
|||||||
|
|
||||||
namespace Wox.Plugin.Sys
|
namespace Wox.Plugin.Sys
|
||||||
{
|
{
|
||||||
public class Sys : IPlugin, ISettingProvider ,IPluginI18n
|
public class Sys : IPlugin, ISettingProvider, IPluginI18n
|
||||||
{
|
{
|
||||||
List<Result> availableResults = new List<Result>();
|
List<Result> availableResults = new List<Result>();
|
||||||
private PluginInitContext context;
|
private PluginInitContext context;
|
||||||
|
|
||||||
#region DllImport
|
#region DllImport
|
||||||
|
|
||||||
internal const int EWX_LOGOFF = 0x00000000;
|
internal const int EWX_LOGOFF = 0x00000000;
|
||||||
internal const int EWX_SHUTDOWN = 0x00000001;
|
internal const int EWX_SHUTDOWN = 0x00000001;
|
||||||
internal const int EWX_REBOOT = 0x00000002;
|
internal const int EWX_REBOOT = 0x00000002;
|
||||||
@@ -26,7 +26,7 @@ namespace Wox.Plugin.Sys
|
|||||||
[DllImport("user32")]
|
[DllImport("user32")]
|
||||||
private static extern void LockWorkStation();
|
private static extern void LockWorkStation();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public System.Windows.Controls.Control CreateSettingPanel()
|
public System.Windows.Controls.Control CreateSettingPanel()
|
||||||
{
|
{
|
||||||
@@ -35,11 +35,6 @@ namespace Wox.Plugin.Sys
|
|||||||
|
|
||||||
public List<Result> Query(Query query)
|
public List<Result> Query(Query query)
|
||||||
{
|
{
|
||||||
if (availableResults.Count == 0)
|
|
||||||
{
|
|
||||||
LoadCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Result> results = new List<Result>();
|
List<Result> results = new List<Result>();
|
||||||
foreach (Result availableResult in availableResults)
|
foreach (Result availableResult in availableResults)
|
||||||
{
|
{
|
||||||
@@ -54,6 +49,7 @@ namespace Wox.Plugin.Sys
|
|||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
LoadCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadCommands()
|
private void LoadCommands()
|
||||||
@@ -153,5 +149,5 @@ namespace Wox.Plugin.Sys
|
|||||||
{
|
{
|
||||||
return context.API.GetTranslation("wox_plugin_sys_plugin_description");
|
return context.API.GetTranslation("wox_plugin_sys_plugin_description");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ using System.Windows.Controls;
|
|||||||
|
|
||||||
namespace Wox.Plugin.Sys
|
namespace Wox.Plugin.Sys
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for SysSettings.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class SysSettings : UserControl
|
public partial class SysSettings : UserControl
|
||||||
{
|
{
|
||||||
public SysSettings(List<Result> Results)
|
public SysSettings(List<Result> Results)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using Wox.Core.i18n;
|
|||||||
using Wox.Core.UserSettings;
|
using Wox.Core.UserSettings;
|
||||||
using Wox.Infrastructure.Http;
|
using Wox.Infrastructure.Http;
|
||||||
using Wox.Infrastructure.Logger;
|
using Wox.Infrastructure.Logger;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace Wox.Core.Updater
|
namespace Wox.Core.Updater
|
||||||
{
|
{
|
||||||
@@ -82,22 +83,25 @@ namespace Wox.Core.Updater
|
|||||||
|
|
||||||
public void CheckUpdate()
|
public void CheckUpdate()
|
||||||
{
|
{
|
||||||
string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
|
ThreadPool.QueueUserWorkItem(o =>
|
||||||
if (!string.IsNullOrEmpty(json))
|
|
||||||
{
|
{
|
||||||
try
|
string json = HttpRequest.Get(VersionCheckURL, HttpProxy.Instance);
|
||||||
|
if (!string.IsNullOrEmpty(json))
|
||||||
{
|
{
|
||||||
NewRelease = JsonConvert.DeserializeObject<Release>(json);
|
try
|
||||||
if (IsNewerThanCurrent(NewRelease) && !UserSettingStorage.Instance.DontPromptUpdateMsg)
|
|
||||||
{
|
{
|
||||||
StartUpdate();
|
NewRelease = JsonConvert.DeserializeObject<Release>(json);
|
||||||
|
if (IsNewerThanCurrent(NewRelease) && !UserSettingStorage.Instance.DontPromptUpdateMsg)
|
||||||
|
{
|
||||||
|
StartUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (System.Exception e)
|
});
|
||||||
{
|
|
||||||
Log.Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartUpdate()
|
private void StartUpdate()
|
||||||
|
|||||||
Reference in New Issue
Block a user