azure-docs-sdk-java/docs-ref-autogen/com.azure.core.util.Progres...

27 строки
3.3 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.core.util.ProgressListener"
fullName: "com.azure.core.util.ProgressListener"
name: "ProgressListener"
nameWithType: "ProgressListener"
summary: "A <xref uid=\"com.azure.core.util.ProgressListener\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ProgressListener\"></xref> is an interface that can be used to listen to the progress of the I/O transfers."
syntax: "public interface **ProgressListener**"
methods:
- uid: "com.azure.core.util.ProgressListener.handleProgress(long)"
fullName: "com.azure.core.util.ProgressListener.handleProgress(long progress)"
name: "handleProgress(long progress)"
nameWithType: "ProgressListener.handleProgress(long progress)"
summary: "The callback function invoked as progress is reported."
modifiers:
- "abstract"
parameters:
- description: "The total progress at the current point of time."
name: "progress"
type: "<xref href=\"long?alt=long&text=long\" data-throw-if-not-resolved=\"False\" />"
syntax: "public abstract void handleProgress(long progress)"
desc: "The callback function invoked as progress is reported.\n\nThe 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."
type: "interface"
desc: "A <xref uid=\"com.azure.core.util.ProgressListener\" data-throw-if-not-resolved=\"false\" data-raw-source=\"ProgressListener\"></xref> is an interface that can be used to listen to the progress of the I/O transfers. The <xref uid=\"com.azure.core.util.ProgressListener.handleProgress(long)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#handleProgress(long)\"></xref> method will be called periodically with the total progress accumulated at the given point of time.\n\n**Code samples**\n\n```java\n/**\n * A simple operation that simulates I/O activity.\n * @param progressReporter The {@link ProgressReporter}.\n */\n public static void simpleOperation(ProgressReporter progressReporter) {\n for (long i = 0; i < 100; i++) {\n // Simulate 100 I/Os with 10 progress.\n progressReporter.reportProgress(10);\n }\n }\n\n /**\n * A complex operation that simulates I/O activity by invoking multiple {@link #simpleOperation(ProgressReporter)}.\n * @param progressReporter The {@link ProgressReporter}.\n */\n public static void complexOperation(ProgressReporter progressReporter) {\n simpleOperation(progressReporter.createChild());\n simpleOperation(progressReporter.createChild());\n simpleOperation(progressReporter.createChild());\n }\n\n /**\n * The main method.\n * @param args Program arguments.\n */\n public static void main(String[] args) {\n // Execute simpleOperation\n ProgressReporter simpleOperationProgressReporter = ProgressReporter\n .withProgressListener(progress -> System.out.println(\"Simple operation progress \" + progress));\n simpleOperation(simpleOperationProgressReporter);\n\n // Execute complexOperation\n ProgressReporter complexOperationProgressReporter = ProgressReporter\n .withProgressListener(progress -> System.out.println(\"Complex operation progress \" + progress));\n complexOperation(complexOperationProgressReporter);\n }\n```"
metadata: {}
package: "com.azure.core.util"
artifact: com.azure:azure-core:1.52.0