You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling CancelAsync for a process started by BeginExecute, the process is not canceled and the result of the command cannot be retrieved.
With enough time for executing the command and without CancelAsync everything works fine:
using (SshClient client = new SshClient(host, username, password))
{
client.Connect();
using (SshCommand command = client.CreateCommand("sleep 10; echo run"))
{
IAsyncResult task = command.BeginExecute();
Thread.Sleep(15000);
//command.CancelAsync();
var result = command.EndExecute(task);
System.Console.WriteLine(result);
}
client.Disconnect();
}
After 15s, the following correctly appears in the console and the execution finishes:
run
If I reduce the sleep to 5s, and uncomment the CancelAsync:
using (SshClient client = new SshClient(host, username, password))
{
client.Connect();
using (SshCommand command = client.CreateCommand("sleep 10; echo run"))
{
IAsyncResult task = command.BeginExecute();
Thread.Sleep(5000);
command.CancelAsync();
var result = command.EndExecute(task);
System.Console.WriteLine(result);
}
client.Disconnect();
}
The process gets blocked at EndExecute instruction, it doesn't finish even though the command hasn't been canceled and it finishes after 10s from the beginning.
The text was updated successfully, but these errors were encountered:
When calling
CancelAsync
for a process started byBeginExecute
, the process is not canceled and the result of the command cannot be retrieved.With enough time for executing the command and without
CancelAsync
everything works fine:After 15s, the following correctly appears in the console and the execution finishes:
If I reduce the sleep to 5s, and uncomment the
CancelAsync
:The process gets blocked at
EndExecute
instruction, it doesn't finish even though the command hasn't been canceled and it finishes after 10s from the beginning.The text was updated successfully, but these errors were encountered: