landelare / ue5coro

A C++20 coroutine implementation for Unreal Engine 5 that feels almost native.
BSD 3-Clause Clear License
543 stars 48 forks source link

[Question] TPromise Example #20

Closed savasozer closed 7 months ago

savasozer commented 7 months ago

First of all, thank you for such an excellent plugin. As a C# guy, I was very happy to find this plugin. It gives me the comfort of C#. But although I could do many things I wanted, I could not see a class that I could use like TaskCompletionSource in C#. I found the TPromise class as the closest alternative. But I think this works a little differently than that.

A 3rd party SDK I use returns the results of API calls via events. I want to wait for these results with TPromise and have my function continue where it left off after the event is called.

1-Is TPromise suitable for this job? 2-An example of usage for this would be great.

Thanks

landelare commented 7 months ago

There's no direct TCS equivalent. You could use a FAwaitableEvent for custom/arbitrary wait conditions, or if this is an Unreal delegate, you can co_await that directly. TPromise from the engine has some design issues and as such I wouldn't recommend its use, but it is supported as much as Unreal allows.

Closing this, since it is not a bug.