Replies: 1 comment 4 replies
-
I tried to implement Task to Promise conversion in that PR #1567. It is working but it's not actually async, it's block the thread until resolve. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
in the long term I want to execute async c# functions in JavaScript. With the recent advantages with async/await and top level awaits I tried integrating these functions again. I understand there is no implicit task/promise conversion so I tried to use the engine.RegisterPromise() method to return a promise using a simple delay method.
As of my understanding this should create a promise that gets resolved in 5 seconds. The promise should be awaitable because of top-level awaits.
This errors with 'Unexpected token' though. I tried wrapping everything in an async method:
But then I get the error 'System.InvalidOperationException: 'UnwrapIfPromise' called before Promise was settled'. This error seems to occur in the .Evaluate() line so I can't even work around that using a task completion source or something.
Is it possible to use await to await a task (converted to promise) in a script at this point? Or is what I'm trying simply not possible now (or ever)? Is there something I am missing?
Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions