Method Refresh
Refresh(bool, CancellationToken)
Synchronously forces a refresh of the current image, performing detection and updating the capture to the latest state.
Declaration
WindowImageProcessedEventArgs<TDetectionResult> Refresh(bool includeImages = false, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includeImages | Whether to include images in the detection results. |
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| WindowImageProcessedEventArgs<TDetectionResult> | A WindowImageProcessedEventArgs<TDetectionResult> containing the detection results. |
Remarks
This method is provided for compatibility and simplicity reasons, allowing for a straightforward, synchronous approach to image refresh and detection. However, it is recommended to use the asynchronous RefreshAsync(bool, CancellationToken) method in conjunction with the await keyword for improved performance and responsiveness, especially in UI applications.
The synchronous refresh performs several critical operations:
- Pulling the latest available image from the image source.
- Initiating the detection process.
- Applying trigger conditions.
- Returning detection results to the caller.
Important considerations:
- The images returned are live references and not static snapshots. Handle these images in a thread-safe manner.
- By default, images are not included in the result. Use the
includeImagesparameter to include them. - Errors encountered during the process are rethrown to the caller.
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown if an error occurs during the refresh process. |
Refresh(CancellationToken)
Synchronously forces a refresh of the current image, performing detection and updating the capture to the latest state.
Declaration
WindowImageProcessedEventArgs<TDetectionResult> Refresh(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| WindowImageProcessedEventArgs<TDetectionResult> | A WindowImageProcessedEventArgs<TDetectionResult> containing the detection results. |
Remarks
This method is provided for compatibility and simplicity reasons, allowing for a straightforward, synchronous approach to image refresh and detection. However, it is recommended to use the asynchronous RefreshAsync(bool, CancellationToken) method in conjunction with the await keyword for improved performance and responsiveness, especially in UI applications.
The synchronous refresh performs several critical operations:
- Pulling the latest available image from the image source.
- Initiating the detection process.
- Applying trigger conditions.
- Returning detection results to the caller.
Important considerations:
- Errors encountered during the process are rethrown to the caller.
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown if an error occurs during the refresh process. |