SshCommand EndExecute Method SSH .NET Client Library Documentation
Waits for the pending asynchronous command execution to complete.

Namespace: Renci.SshNet
Assembly: Renci.SshNet (in Renci.SshNet.dll) Version: 0.1.0.0 (1.0.0.0)
Syntax

public string EndExecute(
	IAsyncResult asyncResult
)

Parameters

asyncResult
Type: OnlineSystem IAsyncResult
The reference to the pending asynchronous request to finish.

Return Value

Command execution result.
Exceptions

ExceptionCondition
OnlineSystem ArgumentExceptionEither the IAsyncResult object did not come from the corresponding async method on this type, or EndExecute was called multiple times with the same IAsyncResult.
OnlineSystem ArgumentExceptionEither the IAsyncResult object did not come from the corresponding async method on this type, or EndExecute was called multiple times with the same IAsyncResult.
Examples

client.Connect();

var cmd = client.CreateCommand("sleep 15s;echo 123"); // Perform long running task 

var asynch = cmd.BeginExecute();

while (!asynch.IsCompleted)
{
    //  Waiting for command to complete...
    Thread.Sleep(2000);
}
result = cmd.EndExecute(asynch);
client.Disconnect();
See Also