wil::wait_for_completion_or_timeout_nothrow() returns E_ILLEGAL_METHOD_CALL (0x8000000e) for timeouts #527
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why is this change being made?
Async operation implementations that inherit from Microsoft::WRL::AsyncBase call Microsoft::WRL::AsyncBase::CheckValidStateForResultsCall() in GetResults() which will return E_ILLEGAL_METHOD_CALL (0x8000000e) when the
resultTypeis AsyncResultType::SingleResult and the async operation hasn't completed yet.The wil::details::WaitForCompletion() overload with a
resultoutput parameter calls GetResults() on the async operation without checking if it timed out first which results in E_ILLEGAL_METHOD_CALL being returned to the caller when an operation times out, rather than S_OK as documented in wil\winrt.h.What changed?
I updated wil::details::WaitForCompletion() to return S_OK and not call GetResults() on the async operation if it timed out.
Resolves #322
How was the change tested?
I updated FakeAsyncOperation::GetResults() to return E_ILLEGAL_METHOD_CALL when the operation has not completed yet, and I added a new test, WinRTTests::WaitForCompletionTimeoutWithResult(), to exercise the timeout behavior for the wil::details::WaitForCompletion() overload with a
resultoutput parameter.I verified that WinRTTests::WaitForCompletionTimeoutWithResult() fails without the change to wil::details::WaitForCompletion() and passes with it.