54 lines
1.1 KiB
C#
54 lines
1.1 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
|
|
{
|
|
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();
|
|
}
|
|
|
|
}
|
|
}
|