FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
CefSharp/CefSharp.WinForms.Example/Program.cs at master · cefsharp/CefSharp · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
cefsharp
/
CefSharp
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2.9k
Star
10.2k
Code
Issues
61
Pull requests
13
Discussions
Actions
Wiki
Security and quality
9
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
CefSharp
/
CefSharp.WinForms.Example
/
Program.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
109 lines (92 loc) · 4.14 KB
Breadcrumbs
CefSharp
/
CefSharp.WinForms.Example
/
Program.cs
Copy path
File metadata and controls
109 lines (92 loc) · 4.14 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright © 2010 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using
System
;
using
System
.
Threading
.
Tasks
;
using
System
.
Windows
.
Forms
;
using
CefSharp
.
Example
;
using
CefSharp
.
Example
.
Handlers
;
using
CefSharp
.
WinForms
.
Example
.
Handlers
;
using
CefSharp
.
WinForms
.
Example
.
Minimal
;
namespace
CefSharp
.
WinForms
.
Example
{
public
class
Program
{
[
STAThread
]
public
static
int
Main
(
string
[
]
args
)
{
// DEMO: Change to true to self host the BrowserSubprocess.
// instead of using CefSharp.BrowserSubprocess.exe, your applications exe will be used.
// In this case CefSharp.WinForms.Example.exe
const
bool
selfHostSubProcess
=
false
;
if
(
selfHostSubProcess
)
{
var
exitCode
=
CefSharp
.
BrowserSubprocess
.
SelfHost
.
Main
(
args
)
;
if
(
exitCode
>=
0
)
{
return
exitCode
;
}
#if
DEBUG
if
(
!
System
.
Diagnostics
.
Debugger
.
IsAttached
)
{
MessageBox
.
Show
(
"When running this Example outside of Visual Studio "
+
"please make sure you compile in `Release` mode."
,
"Warning"
)
;
}
#endif
var
settings
=
new
CefSettings
(
)
;
settings
.
BrowserSubprocessPath
=
System
.
IO
.
Path
.
GetFullPath
(
"CefSharp.WinForms.Example.exe"
)
;
Cef
.
Initialize
(
settings
)
;
Application
.
EnableVisualStyles
(
)
;
var
browser
=
new
SimpleBrowserForm
(
)
;
Application
.
Run
(
browser
)
;
}
else
{
#if
DEBUG
if
(
!
System
.
Diagnostics
.
Debugger
.
IsAttached
)
{
MessageBox
.
Show
(
"When running this Example outside of Visual Studio "
+
"please make sure you compile in `Release` mode."
,
"Warning"
)
;
}
#endif
// DEMO: To integrate CEF into your applications existing message loop
// set multiThreadedMessageLoop = false;
const
bool
multiThreadedMessageLoop
=
true
;
// When multiThreadedMessageLoop = true then externalMessagePump must be set to false
// To enable externalMessagePump set multiThreadedMessageLoop = false and externalMessagePump = true
const
bool
externalMessagePump
=
false
;
//TEST: There are a number of different Forms for testing purposes.
var
browser
=
new
BrowserForm
(
multiThreadedMessageLoop
)
;
//var browser = new SimpleBrowserForm();
//var browser = new TabulationDemoForm();
IBrowserProcessHandler
browserProcessHandler
;
if
(
multiThreadedMessageLoop
)
{
browserProcessHandler
=
new
BrowserProcessHandler
(
)
;
}
else
{
if
(
externalMessagePump
)
{
//Get the current taskScheduler (must be called after the form is created)
var
scheduler
=
TaskScheduler
.
FromCurrentSynchronizationContext
(
)
;
browserProcessHandler
=
new
ScheduleMessagePumpBrowserProcessHandler
(
scheduler
)
;
}
else
{
//We'll add out WinForms timer to the components container so it's Diposed
browserProcessHandler
=
new
WinFormsBrowserProcessHandler
(
browser
.
Components
)
;
}
}
var
settings
=
new
CefSettings
(
)
;
settings
.
MultiThreadedMessageLoop
=
multiThreadedMessageLoop
;
settings
.
ExternalMessagePump
=
externalMessagePump
;
CefExample
.
Init
(
settings
,
browserProcessHandler
:
browserProcessHandler
)
;
Application
.
EnableVisualStyles
(
)
;
//Application.Run(new MultiFormAppContext());
Application
.
Run
(
browser
)
;
}
return
0
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL