mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-04 11:59:07 +08:00
Restored functionality
This commit is contained in:
parent
828e16e88c
commit
28c6847fb6
@ -7,6 +7,7 @@ namespace PowerToys.FileLocksmithUI.ViewModels
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -68,12 +69,12 @@ namespace PowerToys.FileLocksmithUI.ViewModels
|
|||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
Processes.Clear();
|
Processes.Clear();
|
||||||
|
|
||||||
// paths = NativeMethods.ReadPathsFromStdin();
|
paths = NativeMethods.ReadPathsFromFile();
|
||||||
paths = new string[1] { "C:\\Program Files" };
|
|
||||||
|
|
||||||
foreach (ProcessResult p in await FindProcesses(paths))
|
foreach (ProcessResult p in await FindProcesses(paths))
|
||||||
{
|
{
|
||||||
Processes.Add(p);
|
Processes.Add(p);
|
||||||
|
WatchProcess(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
IsLoading = false;
|
IsLoading = false;
|
||||||
@ -89,19 +90,21 @@ namespace PowerToys.FileLocksmithUI.ViewModels
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void WatchProcess(ProcessResult process)
|
||||||
|
{
|
||||||
|
if (await Task.Run(() => NativeMethods.WaitForProcess(process.pid)))
|
||||||
|
{
|
||||||
|
Processes.Remove(process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void EndTask(ProcessResult selectedProcess)
|
public void EndTask(ProcessResult selectedProcess)
|
||||||
{
|
{
|
||||||
Processes.Remove(selectedProcess);
|
if (!NativeMethods.KillProcess(selectedProcess.pid))
|
||||||
|
{
|
||||||
// if (NativeMethods.KillProcess(process.pid))
|
// TODO show something on failure.
|
||||||
// {
|
}
|
||||||
// Processes.Remove(selectedProcess);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // TODO show something on failure.
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
|
Loading…
Reference in New Issue
Block a user