Release AsyncOperationCompletedHandler (#208)
windows: release AsyncOperationCompletedHandler
This commit is contained in:
parent
b8a4a54d5f
commit
83fba1b809
1 changed files with 6 additions and 2 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue