你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
ProgressListener Interface
public interface ProgressListener
A ProgressListener is an interface that can be used to listen to the progress of the I/O transfers. The handleProgress(long progress) method will be called periodically with the total progress accumulated at the given point of time.
Code samples
/**
* A simple operation that simulates I/O activity.
* @param progressReporter The {@link ProgressReporter}.
*/
public static void simpleOperation(ProgressReporter progressReporter) {
for (long i = 0; i < 100; i++) {
// Simulate 100 I/Os with 10 progress.
progressReporter.reportProgress(10);
}
}
/**
* A complex operation that simulates I/O activity by invoking multiple {@link #simpleOperation(ProgressReporter)}.
* @param progressReporter The {@link ProgressReporter}.
*/
public static void complexOperation(ProgressReporter progressReporter) {
simpleOperation(progressReporter.createChild());
simpleOperation(progressReporter.createChild());
simpleOperation(progressReporter.createChild());
}
/**
* The main method.
* @param args Program arguments.
*/
public static void main(String[] args) {
// Execute simpleOperation
ProgressReporter simpleOperationProgressReporter = ProgressReporter
.withProgressListener(progress -> System.out.println("Simple operation progress " + progress));
simpleOperation(simpleOperationProgressReporter);
// Execute complexOperation
ProgressReporter complexOperationProgressReporter = ProgressReporter
.withProgressListener(progress -> System.out.println("Complex operation progress " + progress));
complexOperation(complexOperationProgressReporter);
}
Method Summary
Modifier and Type | Method and Description |
---|---|
abstract void |
handleProgress(long progress)
The callback function invoked as progress is reported. |
Method Details
handleProgress
public abstract void handleProgress(long progress)
The callback function invoked as progress is reported.
The callback can be called concurrently from multiple threads if reporting spans across multiple requests. The implementor must not perform thread blocking operations in the handler code.
Parameters:
Applies to
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈