Files
RemSox/RemSox.Kernel/Processing/Process.cs
T

56 lines
1.4 KiB
C#

using RemSox.Kernel.Logging;
using RemSox.Kernel.Processing.IPC;
using RemSox.Kernel.UI.GUI.Windows;
using System.Drawing;
namespace RemSox.Kernel.Processing;
public abstract class Process(string name)
{
public int Id { get; init; } // Will be set by ProcessManager when the process is spawned
public ILogger Logger { protected get; init; } = null!; // Will be set by ProcessManager when the process is spawned
public string Name { get; set; } = name;
public bool StopRequested { get; private set; } = false;
public bool IsRunning => !StopRequested;
internal virtual void Start(string[] args) { }
internal abstract void Tick();
internal virtual void Stop() { }
internal virtual void HandleInterProcessMessage(Message message)
{
}
protected Window CreateWindow(string title, Size size)
{
return WindowManager.CreateWindow(this, title, size);
}
protected Window CreateWindow(string title, Size size, Point position)
{
return WindowManager.CreateWindow(this, title, size, position);
}
protected void SendMessageToProcess(int targetProcessId, Message message)
{
InterProcessCommunicator.Send(targetProcessId, message, this);
}
protected void SendMessageToAllProcesses(Message message)
{
InterProcessCommunicator.SendToAll(message, this);
}
internal void RequestStop()
{
StopRequested = true;
}
}