Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
78155ccb
Commit
78155ccb
authored
May 16, 2017
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue with console quickedit mode where app hangs until key press
parent
5c4fc480
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
Program.cs
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
+10
-1
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
View file @
78155ccb
using
System
;
using
System
;
using
System.Diagnostics
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
namespace
Titanium.Web.Proxy.Examples.Basic
namespace
Titanium.Web.Proxy.Examples.Basic
...
@@ -9,11 +10,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -9,11 +10,14 @@ namespace Titanium.Web.Proxy.Examples.Basic
public
static
void
Main
(
string
[]
args
)
public
static
void
Main
(
string
[]
args
)
{
{
//fix console hang due to QuickEdit mode
var
handle
=
Process
.
GetCurrentProcess
().
MainWindowHandle
;
NativeMethods
.
SetConsoleMode
(
handle
,
NativeMethods
.
ENABLE_EXTENDED_FLAGS
);
//On Console exit make sure we also exit the proxy
//On Console exit make sure we also exit the proxy
NativeMethods
.
Handler
=
ConsoleEventCallback
;
NativeMethods
.
Handler
=
ConsoleEventCallback
;
NativeMethods
.
SetConsoleCtrlHandler
(
NativeMethods
.
Handler
,
true
);
NativeMethods
.
SetConsoleCtrlHandler
(
NativeMethods
.
Handler
,
true
);
//Start proxy controller
//Start proxy controller
controller
.
StartProxy
();
controller
.
StartProxy
();
...
@@ -42,6 +46,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -42,6 +46,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
internal
static
class
NativeMethods
internal
static
class
NativeMethods
{
{
internal
const
uint
ENABLE_EXTENDED_FLAGS
=
0x0080
;
// Keeps it from getting garbage collected
// Keeps it from getting garbage collected
internal
static
ConsoleEventDelegate
Handler
;
internal
static
ConsoleEventDelegate
Handler
;
...
@@ -50,5 +56,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -50,5 +56,8 @@ namespace Titanium.Web.Proxy.Examples.Basic
// Pinvoke
// Pinvoke
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
internal
delegate
bool
ConsoleEventDelegate
(
int
eventType
);
[
DllImport
(
"kernel32.dll"
)]
internal
static
extern
bool
SetConsoleMode
(
IntPtr
hConsoleHandle
,
uint
dwMode
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment