I am using cefsharp.Wpf and I need to run 2 commands togheter.
This is the object I am binding to my javascript
public class CefSharpCommonObject
{
public dynamic Start()
{
var response = dummyProc.Start();
return new
{
response.IsSuccess
};
}
public dynamic Stop()
{
var response = dummyProc.Stop();
return new
{
response.IsSuccess
};
}
}
Like the following:
cefBrowser.JavascriptObjectRepository.Register("jsCommunicator", new CefSharpCommonObject(), true);
I call the start method using:
<script type="text/javascript">
(async () => {
await CefSharp.BindObjectAsync("jsCommunicator", "jsTest");
jsCommunicator.start().then(() => {}, () => {});
setTimeout(jsCommunicator.stop, 5000);
})();
</script>
The start method uses a while loop that checks something and then sleeps for 1 second and I fear it may be blocking the UI thread because the stop method isn't being called. Only after the start method auto exits after like 30 seconds.
Is there a way I can make the start method a task so I can run it in another thread and still get the return value after it stops?