Hi,
I'm currently trying to implement a Job Manager in C# that executes various tasks on Linux and Windows machines via SSH. The idea is to asynchronously execute the task so that the Job Manager can monitor in case the user aborts the job (The job manager is multi-threaded to allow multiple jobs to execute at once).
If the user does abort the job, this is where the problems come in. I'm using CancelAsync() to try and cancel the running process on the remote machine, but for some reason it will always time out and not abort the remote process. Any advice on what I might be doing wrong / could do differently / investigate further would be much appreciate! Sample code for the manager thread below:
Mike
I'm currently trying to implement a Job Manager in C# that executes various tasks on Linux and Windows machines via SSH. The idea is to asynchronously execute the task so that the Job Manager can monitor in case the user aborts the job (The job manager is multi-threaded to allow multiple jobs to execute at once).
If the user does abort the job, this is where the problems come in. I'm using CancelAsync() to try and cancel the running process on the remote machine, but for some reason it will always time out and not abort the remote process. Any advice on what I might be doing wrong / could do differently / investigate further would be much appreciate! Sample code for the manager thread below:
client.Connect();
var cmd = client.CreateCommand("python /my/python/script.py 1 2 3");
var async = cmd.BeginExecute();
while (!async.IsComplete)
{
Thread.Sleep(2000);
if (job.State == jobState.Aborted)
{
cmd.CancelAsync();
}
}
cmd.EndExecute(async);
...
client.Disconnect();
Many thanks!Mike