Skip to content

Commit 7d26605

Browse files
committed
WinForms Example - Add demo that reproduces #2928
1 parent 2c623ab commit 7d26605

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
<Compile Include="InputBox.Designer.cs">
100100
<DependentUpon>InputBox.cs</DependentUpon>
101101
</Compile>
102+
<Compile Include="Minimal\MultiFormAppContext.cs" />
102103
<Compile Include="Minimal\SimpleBrowserForm.cs">
103104
<SubType>Form</SubType>
104105
</Compile>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright © 2019 The CefSharp Authors. All rights reserved.
2+
//
3+
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4+
5+
using System.Windows.Forms;
6+
7+
namespace CefSharp.WinForms.Example.Minimal
8+
{
9+
public class MultiFormAppContext : ApplicationContext
10+
{
11+
private SimpleBrowserForm form1;
12+
private SimpleBrowserForm form2;
13+
14+
public MultiFormAppContext(bool multiThreadedMessageLoop)
15+
{
16+
form1 = new SimpleBrowserForm(multiThreadedMessageLoop);
17+
form1.WindowState = FormWindowState.Normal;
18+
form2 = new SimpleBrowserForm(multiThreadedMessageLoop);
19+
form2.WindowState = FormWindowState.Normal;
20+
21+
form1.FormClosed += OnFormClosed;
22+
form2.FormClosed += OnFormClosed;
23+
24+
form1.Show();
25+
form2.Show();
26+
}
27+
28+
private void OnFormClosed(object sender, FormClosedEventArgs e)
29+
{
30+
if (Application.OpenForms.Count == 0)
31+
{
32+
ExitThread();
33+
}
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)