-
Notifications
You must be signed in to change notification settings - Fork 315
Expand file tree
/
Copy pathAsyncHandlers.h
More file actions
63 lines (52 loc) · 2.33 KB
/
AsyncHandlers.h
File metadata and controls
63 lines (52 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE.md in the repo root for license information.
#pragma once
//
// Async Handlers Header
//
// Event-driven async operation handlers for Windows ML ABI interfaces.
// Provides progress reporting and completion notification with HANDLE-based synchronization.
//
#include <wrl/implements.h>
#include <functional>
#include "Microsoft.Windows.AI.MachineLearning.h"
#include "Windows.Foundation.h"
namespace CppAbiEPEnumerationSample
{
/// <summary>
/// Progress handler for async operations with progress reporting
/// </summary>
class ProgressHandler : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
__FIAsyncOperationProgressHandler_2_Microsoft__CWindows__CAI__CMachineLearning__CExecutionProviderReadyResult_double>
{
public:
ProgressHandler(std::function<void(double)> callback);
// IAsyncOperationProgressHandler implementation
IFACEMETHOD(Invoke)(
__FIAsyncOperationWithProgress_2_Microsoft__CWindows__CAI__CMachineLearning__CExecutionProviderReadyResult_double* asyncInfo,
double progressInfo) override;
private:
std::function<void(double)> m_callback;
};
/// <summary>
/// Completion handler for async operations with event synchronization
/// </summary>
class CompletionHandler : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
__FIAsyncOperationWithProgressCompletedHandler_2_Microsoft__CWindows__CAI__CMachineLearning__CExecutionProviderReadyResult_double>
{
public:
CompletionHandler(HANDLE completionEvent);
// IAsyncOperationWithProgressCompletedHandler implementation
IFACEMETHOD(Invoke)(
__FIAsyncOperationWithProgress_2_Microsoft__CWindows__CAI__CMachineLearning__CExecutionProviderReadyResult_double* asyncInfo,
ABI::Windows::Foundation::AsyncStatus asyncStatus) override;
ABI::Windows::Foundation::AsyncStatus GetStatus() const;
HRESULT GetErrorCode() const;
private:
const HANDLE m_completionEvent;
ABI::Windows::Foundation::AsyncStatus m_status;
HRESULT m_errorCode;
};
} // namespace CppAbiEPEnumerationSample