I have a c++ class object which performs some processing in the background of a uwp application.
Its process operation is called by Unity's "Update" method ~60fps through an UWP IAsyncOperation
.
The class has a isBusy
property which is set to true
after calling the operation, in order to block it being called from unity again before it finishes.
Using task continuation, I would like to set this to false after the processing is complete and returned through the IAsyncOperation
.
IAsyncOperation<ResultsWrapper^>^ SomeClass::SomeClassUpdateMethod() {
return concurrency::create_async([this]() -> ResultsWrapper^
{
// Block processing
SomeClass::isBusy = true;
// Process image and return to await
LongRunningTask().then([this]() {
return SomeClass::TaskResults;
}).then([this]() {
isBusy = false;
});
});
}
concurrency::task<void> SomeClass::LongRunningTask(){
auto results = ref new TaskResults();
'''Work happens here'''
SomeClass::TaskResults = results;
}
What I expect to happen is for the ResultWrapper
object to be returned to the main thread of the calling application (Unity), then the isBusy
flag of the object set to false by the task continuation.
What happens is:
Error C2338 incorrect parameter type for the callable object in 'then'; consider _ExpectedParameterType or task<_ExpectedParameterType> (see below) \....\include\ppltasks.h