Release AsyncOperationCompletedHandler (#208)

windows: release AsyncOperationCompletedHandler
This commit is contained in:
Anton Onipko 2024-01-04 21:28:49 +02:00 committed by GitHub
parent b8a4a54d5f
commit 83fba1b809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,14 @@ func awaitAsyncOperation(asyncOperation *foundation.IAsyncOperation, genericPara
// Wait until the async operation completes. // Wait until the async operation completes.
waitChan := make(chan struct{}) waitChan := make(chan struct{})
asyncOperation.SetCompleted(foundation.NewAsyncOperationCompletedHandler(ole.NewGUID(iid), func(instance *foundation.AsyncOperationCompletedHandler, asyncInfo *foundation.IAsyncOperation, asyncStatus foundation.AsyncStatus) { handler := foundation.NewAsyncOperationCompletedHandler(ole.NewGUID(iid), func(instance *foundation.AsyncOperationCompletedHandler, asyncInfo *foundation.IAsyncOperation, asyncStatus foundation.AsyncStatus) {
status = asyncStatus status = asyncStatus
close(waitChan) close(waitChan)
})) })
defer handler.Release()
asyncOperation.SetCompleted(handler)
// Wait until async operation has stopped, and finish. // Wait until async operation has stopped, and finish.
<-waitChan <-waitChan