Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Form hangs during the FormClosing event Options
pf-fvhe
Posted: Friday, April 12, 2019 10:44:13 AM
Rank: Advanced Member
Groups: Member

Joined: 10/24/2018
Posts: 39
We just discovered an issue in the WinForms implementation of the WebBrowser control.

In our application we have a form that contains a WebControl, and we have attached a FormClosing event handler in order to ask the user whether the form should really be closed if there are still unsaved changes in progress. Please note that we also have a CancelButton specified on the form.

When the form is closed we display a MessageBox, and when the MessageBox is displayed the application seems to hang or deadlock.

Code to reproduce this issue:
Quote:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

using EO.WebBrowser;
using EO.WinForm;

namespace EOTest
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

Application.Run(CreateTestForm());
}

private static Form CreateTestForm()
{
EO.WebEngine.Engine.Default.Options.DisableGPU = true;

var form = new Form1();

var webControl = new WebControl
{
Dock = DockStyle.Fill,
TabStop = false
};

var webView = new WebView
{
Url = "https://www.google.com"
};
webControl.WebView = webView;

form.Controls.Add(webControl);

Button btn = new Button();
btn.Click += (sender, e) => {
form.Close();
webView.Dispose();
webControl.Dispose();
};
form.Controls.Add(btn);
btn.Dock = DockStyle.Top;
form.CancelButton = btn;

form.FormClosing += (sender, e) =>
{
var dialogResult = MessageBox.Show("You have unsaved changes, are you sure you want to exit?", "Are you sure?", MessageBoxButtons.YesNoCancel);
switch (dialogResult)
{
case DialogResult.Cancel:
case DialogResult.No:
e.Cancel = true;
break;
default:
break;
}
};

var textBox = new TextBox
{
Dock = DockStyle.Bottom
};
form.Controls.Add(textBox);

return form;
}
}
}


Steps to reproduce this issue:
1. Put the focus inside the webbrowser, for example in the search bar of Google.
2. Press ESC.
3. Observe that the application hangs.

We expect the application to not hang.
eo_support
Posted: Friday, April 12, 2019 11:57:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,194
Hi,

You will need to update your Windows. This is the same issue discussed here:

https://www.essentialobjects.com/forum/postst11088p2_Form-started-from-webbrowser-is-shown-under-current-form.aspx#47149

The root of the problem is a bug in Windows 1703 related Windows message dispatching, which Microsoft has already fixed. It is not possible for us to patch around all cases since the real problem is not in our code. So you should update your Windows instead of keep beating an outdated version and trying to patch around it.

Thanks!
pf-fvhe
Posted: Tuesday, April 16, 2019 8:49:20 AM
Rank: Advanced Member
Groups: Member

Joined: 10/24/2018
Posts: 39
Good afternoon,

You are correct, updating to Windows 1703 solved this issue.
eo_support
Posted: Tuesday, April 16, 2019 9:19:56 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 21,194
Great. Thanks for confirming!


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.