How to wait for async task to finish in UPL

Hi,

I’m creating a UPL plugin which has a listener callback on the Java side. I would like to know how I can wait for the callback to finish before I continue with my execution?

I’ve tried the following and both return the value before executing my listener.

Locks:

Using a synchronous lock and using notifyAll() once I reach the listener method.
This ended up blocking my UI thread and never got released.

CountdownLatch:

Used latch.await() and latch.countdown() methods. But that didn’t wait for my listeners to finish calling either. Is there a better way to do this?

Thanks.

Look in source of OnlineSubsystem module:

Engine\Plugins\Online\OnlineSubsystemUtils\Source\OnlineSubsystemUtils\Classes\ShowLoginUICallbackProxy.h

Engine\Plugins\Online\OnlineSubsystemUtils\Source\OnlineSubsystemUtils\Private\ShowLoginUICallbackProxy.cpp