|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
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!
|
|
Rank: Advanced Member Groups: Member
Joined: 10/10/2016 Posts: 35
|
Hi EO,
Okay, thanks very much.
Regards, Qiang
|
|