2024-07-06 18:08:57 +03:00

55 lines
1.2 KiB
C#

using Esiur.Resource;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AZ.Compute.Agent
{
[Resource]
public partial class Job
{
[Export] int id;
[Export] string name;
[Export] string command;
[Export] DateTime start = DateTime.Now;
[Export] DateTime finish;
[Export] bool finished;
[Export] object results;
[Export] float cpu;
[Export] float ram;
Process process;
public Process Process
{
get => process;
set
{
value.EnableRaisingEvents = true;
process = value;
Name = process.ProcessName;
Command = process.StartInfo.Arguments;
Id = process.Id;
process.Exited += Process_Exited;
}
}
private void Process_Exited(object? sender, EventArgs e)
{
Finished = true;
Finish = DateTime.Now;
}
[Export]
public void Kill()
{
process?.Kill();
}
}
}