up
This commit is contained in:
53
AZ.Compute.Agent/Job.cs
Normal file
53
AZ.Compute.Agent/Job.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user