mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Refactoring multithreading
1. ThreadPool -> Task 2. fix deadlock 3. remove unnecessory application.dispatcher.invoke 4. enable non-main thread access to results collection 5. Misc 6. part of #412
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
@@ -40,7 +41,7 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
if (!isIndexing)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
Programs.IndexPrograms();
|
||||
isIndexing = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Wox.Plugin.Program
|
||||
private void ReIndexing()
|
||||
{
|
||||
programSourceView.Items.Refresh();
|
||||
ThreadPool.QueueUserWorkItem(t =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
|
||||
Programs.IndexPrograms();
|
||||
|
||||
Reference in New Issue
Block a user