[EDIT] This problem appears only in debug mode, without attached debugger / in release mode it works as expected. VS2022
Hi, I have made the following observation when using HostObjects:
In my application, I am executing native code in C# through a JS call. The corresponding method opens an OpenFileDialog on the C# side, a file can be selected and you get the path back - so far it works quite well.
Now, if I don't make any selection in the dialog and just do nothing, after a few seconds (around 10s) the whole program terminates and dies.
Apparently the waiting Promise on JS side causes this crash?
Since my customers are sometimes "a bit slow" in selecting their files, or will spend a long time searching in their folders, of course the 10 seconds are not enough here.
Is there any explanation for this phenomenon or any way to stop this behavior?
JS-Side
// I have omitted all checks for clarity to show the basic problem
class DotNet {
static SelectJobFile() {
return window.chrome.webview.hostObjects.dotnet['SelectJobFile']();
}
}
// ...the method will be called later in an asyncronous function
let filePath = await DotNet.SelectJobFile();
C#-Side
// instance is registered as "dotnet" in webviews hostObjects
public class UIDotNetInterop
{
public string SelectJobFile()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
if (openFileDialog.ShowDialog() == true)
{
Debug.WriteLine(openFileDialog.FileName);
return openFileDialog.FileName;
}
else
{
return "";
}
}
}
[EDIT] This problem appears only in debug mode, without attached debugger / in release mode it works as expected. VS2022
Hi, I have made the following observation when using HostObjects:
In my application, I am executing native code in C# through a JS call. The corresponding method opens an OpenFileDialog on the C# side, a file can be selected and you get the path back - so far it works quite well.
Now, if I don't make any selection in the dialog and just do nothing, after a few seconds (around 10s) the whole program terminates and dies.
Apparently the waiting Promise on JS side causes this crash?
Since my customers are sometimes "a bit slow" in selecting their files, or will spend a long time searching in their folders, of course the 10 seconds are not enough here.
Is there any explanation for this phenomenon or any way to stop this behavior?
JS-Side
C#-Side