Support for intermediate results in IAsync...WithProgress
objects
#1485
Labels
enhancement
New feature or request
IAsync...WithProgress
objects
#1485
Proposal: Support for intermediate results in
IAsync...WithProgress
objectsSummary
Currently, the code
CsWinRT/src/cswinrt/strings/additions/Windows.Foundation/TaskToAsyncInfoAdapter.cs
Lines 729 to 730 in 70e9541
prevents retrieving any result value before the
Task
is complete. This feature proposes some ability to set an intermediate result object that could be returned instead of an error.Rationale
Clients of
IAsync...WithProgress
are permitted to callGetResults()
before the operation has completed, allowing them to observe partial results. This behavior is beneficial for scenarios with non-linear progress. For example, when processing a batch of items, the progress may be for a single item while the intermediate result contains the complete set.Important Notes
C++/WinRT added this feature with microsoft/cppwinrt#870
A quick read of the code suggests that adding an overload to
CsWinRT/src/cswinrt/strings/additions/Windows.Foundation/AsyncInfo.cs
Lines 110 to 111 in 70e9541
to take a result object and return it as the value when
GetResults
is called would provide the minimum required functionality. A choice could be made to require that theTask
result was this same object or not (C++/WinRT does not require that).An alternative solution would be to also pass an
IProgress<TResult>
in to thetaskProvider
, allowing for the intermediate result object to be set inside the task body and also for it to change dynamically, similar to the C++/WinRT implementation.Open Questions
Task
itself offers no support, as it only offers a block-until-completionResult
property.The text was updated successfully, but these errors were encountered: