[英]CefSharp Javascript Callback never return resolved promise
首先,請原諒我的英語,它非常糟糕。 我在 WinForms 應用程序中使用 CefSharp 在導航器和 .NET 代碼之間進行通信。
I'm trying to resolve a promise in an asynchronous callback function with CefSharp, but in the response returned to.Net I never get the response of the resolved promise, but rather an object that seems to represent the consumers of said promise (finally,抓住,然后)。
有沒有辦法解決這個問題?
我留下一個例子,希望能幫助你理解這個問題。
//C#代碼
public void TestCallback(IJavascriptCallback javascriptCallback)
{
const int taskDelay = 1500;
Task.Run(async () =>
{
await Task.Delay(taskDelay);
using (javascriptCallback)
{
var result = await javascriptCallback.ExecuteAsync();
//result is a JavaScriptResponse, but property "Result" is not "user" object, is a dictionary object with 'then', 'catch', 'finally' keys.
}
});
}
//JS代碼
function async MyCallback()
{
// read our JSON
let response = await fetch('/article/promise-chaining/user.json');
let user = await response.json();
return user;
}
boundAsync.testCallback(MyCallback);
非常感謝。
問候
博爾哈
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.