public byte[] RequestRead(byte[] handle, ulong offset, uint length)
{
SshException exception = null;
byte[] data = null;
using (var wait = new AutoResetEvent(false))
{
var request = new SftpReadRequest(ProtocolVersion, NextRequestId, handle, offset, length,
response =>
{
data = response.Data;
wait.Set();
},
response =>
{
if (response.StatusCode != StatusCodes.Eof)
{
exception = GetSftpException(response);
}
data = Array<byte>.Empty;
wait.Set();
});
SendRequest(request);
WaitOnHandle(wait, OperationTimeout);
}
if (exception != null)
{
throw exception;
}
return data;
}