Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ public async Task InitAsync(PluginInitContext context)
{
_context = context;

await Task.Run(() =>
{
_settings = _settingsStorage.Load();
_settings = _settingsStorage.Load();

Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Preload programs cost", () =>
{
_win32Storage = new BinaryStorage<Win32[]>("Win32");
_win32s = _win32Storage.TryLoad(new Win32[] { });
_uwpStorage = new BinaryStorage<UWP.Application[]>("UWP");
_uwps = _uwpStorage.TryLoad(new UWP.Application[] { });
});
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>");
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>");
await Task.Yield();

Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Preload programs cost", () =>
{
_win32Storage = new BinaryStorage<Win32[]>("Win32");
_win32s = _win32Storage.TryLoad(new Win32[] { });
_uwpStorage = new BinaryStorage<UWP.Application[]>("UWP");
_uwps = _uwpStorage.TryLoad(new UWP.Application[] { });
});
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload win32 programs <{_win32s.Length}>");
Log.Info($"|Flow.Launcher.Plugin.Program.Main|Number of preload uwps <{_uwps.Length}>");


bool indexedWinApps = false;
bool indexedUWPApps = false;
Expand All @@ -121,37 +121,35 @@ await Task.Run(() =>
}
});

await Task.WhenAll(a, b);

if (indexedWinApps && indexedUWPApps)
_settings.LastIndexTime = DateTime.Today;
var indexTask = Task.WhenAll(a, b).ContinueWith(t =>
{
if (indexedWinApps && indexedUWPApps)
_settings.LastIndexTime = DateTime.Today;
});

if (!(_win32s.Any() && _uwps.Any()))
await indexTask;
}

public static void IndexWin32Programs()
{
var win32S = Win32.All(_settings);

_win32s = win32S;
}

public static void IndexUwpPrograms()
{
var windows10 = new Version(10, 0);
var support = Environment.OSVersion.Version.Major >= windows10.Major;

var applications = support ? UWP.All() : new UWP.Application[] { };

_uwps = applications;
}

public static async Task IndexPrograms()
{
var t1 = Task.Run(IndexWin32Programs);

var t2 = Task.Run(IndexUwpPrograms);

await Task.WhenAll(t1, t2).ConfigureAwait(false);

_settings.LastIndexTime = DateTime.Today;
}

Expand Down Expand Up @@ -245,4 +243,4 @@ public async Task ReloadDataAsync()
await IndexPrograms();
}
}
}
}
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Program/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Name": "Program",
"Description": "Search programs in Flow.Launcher",
"Author": "qianlifeng",
"Version": "1.4.3",
"Version": "1.4.4",
"Language": "csharp",
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",
Expand Down