You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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!
The text was updated successfully, but these errors were encountered:
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.
You can follow up in the pr. I hope PR helps to you :)
Repository owner
locked and limited conversation to collaborators
Jul 31, 2023
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!
The text was updated successfully, but these errors were encountered: