Welcome Guest Search | Active Topics | Sign In | Register

A question about Promise Options
Qiang
Posted: Tuesday, April 25, 2017 5:52:56 AM
Rank: Advanced Member
Groups: Member

Joined: 10/10/2016
Posts: 35
Hi EO,

I have one question. I use "eoWebBrowser.extInvoke" function to call C# code, but if the C# code needs a lot of time, it will block the UI now. I can fix this problem by myself, something like callback function.(Please let me know if EO has a better way.) But I want to know, does EO has any plan to support Promise object?

Code: JavaScript
const extInvokeAsync = (theKey, theArray) => {
    return new Promise((resolve, reject) => {
        if (typeof (eoapi) === "object") {
            [color=orange]const result = eoWebBrowser.extInvoke(theKey, theArray);[/color]
            resolve(result);
        } else {
            reject(new Error("error!"));
        }
    });
};


Thanks & Regards,
Qiang
eo_support
Posted: Tuesday, April 25, 2017 9:57:08 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

Thank you very much for your feedback. The promise has to be supported natively by extInvoke in order to avoid blocking the UI. This is because the render process runs JavaScript code in the main UI thread, so as long as any JavaScript code blocks (as the case for extInvoke), it will block the UI. The easiest solution for now is as you noticed to use a callback. In another word, instead of making JavaScript code asynchronous, you can make your C# side code asynchronous and callback the JavaScript callback object once you are done.

Thanks!
Qiang
Posted: Tuesday, April 25, 2017 9:35:48 PM
Rank: Advanced Member
Groups: Member

Joined: 10/10/2016
Posts: 35
Hi EO,

Okay, thanks very much.

Regards,
Qiang


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.