public static AsyncActionWithProgress <ulong> DownloadAsyncWithProgress(this Renci.SshNet.SftpClient sftpClient, string path, Stream targetStream) { return(new AsyncActionWithProgress <ulong>((callBack, state, progressCallback) => sftpClient.BeginDownloadFile(path, targetStream, callBack, state, progressCallback), asyncResult => sftpClient.EndDownloadFile(asyncResult), null)); }