Class SftpProgressHandler
Base class for monitoring SFTP operations. Override the methods you are interested in.
public abstract class SftpProgressHandler
- Inheritance
-
SftpProgressHandler
- Inherited Members
Remarks
Callbacks are invoked inline. Progress reporting should be deferred to the UI thread.
Start(int) is always called synchronously before the async method returns its ValueTask. Completed(Exception?) is called at the end, including when the operation fails.
Entries are identified by an index parameter. For single-entry operations the index is always 0.
For multi-entry operations, indexes are assigned and reused as entries finish.
The index value is always less than the maxConcurrentEntries argument passed to Start(int).
For each discovered entry, EntryStart(int, UnixFileType, Entry) is called. DataTransferred(int, long, long) is called for each chunk of data that is successfully transferred. When the entry is successfully handled, EntryCompleted(int, UnixFileType) is called. If a discovered entry is not found and this is not a failure, EntrySkipped(int, UnixFileType) is called instead of EntryCompleted(int, UnixFileType).
After all entries have been discovered, EntriesDiscovered() is called and no more EntryStart(int, UnixFileType, Entry) calls will follow.
EntryStart(int, UnixFileType, Entry) calls are always sequential. EntryCompleted(int, UnixFileType), EntrySkipped(int, UnixFileType), and DataTransferred(int, long, long) may be called concurrently for different entries but are sequential for the same entry.
Because EntryStart(int, UnixFileType, Entry) calls are sequential, they can be used to resize an array that tracks per-entry information using the index as position. Each new entry can fill in its information at start. Note that clearing information when an entry finishes may be lost if the array is resized by a concurrent EntryStart(int, UnixFileType, Entry) call.
For per-entry DataTransferred(int, long, long) information, resizing does not work because it would affect tracking for on-going entries. A fixed-size array of maxConcurrentEntries elements can be used instead.
Fields
MaxConcurrentTransferEntries
The maximum number of concurrent entries for upload and download operations (64).
public const int MaxConcurrentTransferEntries = 64
Field Value
Methods
Completed(Exception?)
Called when the operation finishes.
protected virtual void Completed(Exception? exception)
Parameters
DataTransferred(int, long, long)
Called when data is transferred.
protected virtual void DataTransferred(int index, long bytesTransferred, long offset)
Parameters
indexintThe index of the entry.
bytesTransferredlongThe additional number of bytes transferred.
offsetlongThe position in the remote file after the transfer.
EntriesDiscovered()
Called when all entries have been discovered. No more EntryStart(int, UnixFileType, Entry) calls will follow.
protected virtual void EntriesDiscovered()
EntryCompleted(int, UnixFileType)
Called when an entry has been successfully handled.
protected virtual void EntryCompleted(int index, UnixFileType type)
Parameters
indexintThe index of the entry.
typeUnixFileTypeThe type of entry.
EntrySkipped(int, UnixFileType)
Called when an entry was skipped because it was not found at the time of transfer.
protected virtual void EntrySkipped(int index, UnixFileType type)
Parameters
indexintThe index of the entry.
typeUnixFileTypeThe type of entry.
Remarks
The default implementation calls EntryCompleted(int, UnixFileType).
EntryStart(int, UnixFileType, Entry)
Called when handling of an entry starts.
protected virtual void EntryStart(int index, UnixFileType type, SftpProgressHandler.Entry entry)
Parameters
indexintThe index of the entry in discovery order.
typeUnixFileTypeThe type of entry.
entrySftpProgressHandler.EntryInformation about the entry.
Start(int)
Called when the operation starts.
protected virtual void Start(int maxConcurrentEntries)
Parameters
maxConcurrentEntriesintThe upper bound for entry indices used during this operation.