mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 17:16:24 +02:00
Code cleanup
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using RemSox.Processing;
|
||||
|
||||
namespace RemSox.Processing.IPC;
|
||||
|
||||
internal static class InterProcessCommunicator
|
||||
@@ -15,7 +12,7 @@ internal static class InterProcessCommunicator
|
||||
{
|
||||
message.SenderProcessId = sender.Id; // automatically set
|
||||
|
||||
foreach (var process in ProcessManager.GetAllProcesses())
|
||||
foreach (Process process in ProcessManager.GetAllProcesses())
|
||||
{
|
||||
process.HandleInterProcessMessage(message);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System;
|
||||
|
||||
namespace RemSox.Processing.IPC;
|
||||
|
||||
public abstract class Message
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using RemSox.Processing.IPC;
|
||||
|
||||
namespace RemSox.Processing;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using RemSox.UI.GUI.Windows;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace RemSox.Processing;
|
||||
|
||||
public static class ProcessManager
|
||||
@@ -31,12 +31,12 @@ public static class ProcessManager
|
||||
}
|
||||
finally
|
||||
{
|
||||
processes.TryRemove(id, out _);
|
||||
_ = processes.TryRemove(id, out _);
|
||||
WindowManager.CloseWindowsForProcess(id);
|
||||
}
|
||||
});
|
||||
|
||||
processes.TryAdd(id, (process, thread));
|
||||
_ = processes.TryAdd(id, (process, thread));
|
||||
|
||||
thread.Start();
|
||||
|
||||
@@ -45,19 +45,21 @@ public static class ProcessManager
|
||||
|
||||
public static void StopProcess(int processId)
|
||||
{
|
||||
if (!processes.TryGetValue(processId, out var entry))
|
||||
if (!processes.TryGetValue(processId, out (Process Process, Thread Thread) entry))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
entry.Process.RequestStop();
|
||||
|
||||
WindowManager.CloseWindowsForProcess(processId);
|
||||
|
||||
processes.TryRemove(processId, out _);
|
||||
_ = processes.TryRemove(processId, out _);
|
||||
}
|
||||
|
||||
public static void StopAllProcesses()
|
||||
{
|
||||
foreach (var entry in processes.Values)
|
||||
foreach ((Process Process, Thread Thread) entry in processes.Values)
|
||||
{
|
||||
StopProcess(entry.Process.Id);
|
||||
}
|
||||
@@ -67,7 +69,7 @@ public static class ProcessManager
|
||||
|
||||
public static Process? GetProcess(int processId)
|
||||
{
|
||||
if (processes.TryGetValue(processId, out var entry))
|
||||
if (processes.TryGetValue(processId, out (Process Process, Thread Thread) entry))
|
||||
{
|
||||
return entry.Process;
|
||||
}
|
||||
@@ -77,7 +79,7 @@ public static class ProcessManager
|
||||
|
||||
public static IEnumerable<Process> GetAllProcesses()
|
||||
{
|
||||
foreach (var entry in processes.Values)
|
||||
foreach ((Process Process, Thread Thread) entry in processes.Values)
|
||||
{
|
||||
yield return entry.Process;
|
||||
}
|
||||
@@ -85,7 +87,7 @@ public static class ProcessManager
|
||||
|
||||
public static bool TryGetProcess(int processId, out Process? process)
|
||||
{
|
||||
if (processes.TryGetValue(processId, out var entry))
|
||||
if (processes.TryGetValue(processId, out (Process Process, Thread Thread) entry))
|
||||
{
|
||||
process = entry.Process;
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user