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
d8ba1b88
Commit
d8ba1b88
authored
May 16, 2017
by
justcoding121
Committed by
justcoding121
May 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable quick edit causing app hang
parent
430e1c47
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
6 deletions
+56
-6
ConsoleHelper.cs
...itanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
+52
-0
Program.cs
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
+3
-6
Titanium.Web.Proxy.Examples.Basic.csproj
...y.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
+1
-0
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/Helpers/ConsoleHelper.cs
0 → 100644
View file @
d8ba1b88
using
System
;
using
System.Runtime.InteropServices
;
namespace
Titanium.Web.Proxy.Examples.Basic.Helpers
{
/// <summary>
/// Adapated from
/// http://stackoverflow.com/questions/13656846/how-to-programmatic-disable-c-sharp-console-applications-quick-edit-mode
/// </summary>
internal
static
class
ConsoleHelper
{
const
uint
ENABLE_QUICK_EDIT
=
0x0040
;
// STD_INPUT_HANDLE (DWORD): -10 is the standard input device.
const
int
STD_INPUT_HANDLE
=
-
10
;
[
DllImport
(
"kernel32.dll"
,
SetLastError
=
true
)]
static
extern
IntPtr
GetStdHandle
(
int
nStdHandle
);
[
DllImport
(
"kernel32.dll"
)]
static
extern
bool
GetConsoleMode
(
IntPtr
hConsoleHandle
,
out
uint
lpMode
);
[
DllImport
(
"kernel32.dll"
)]
static
extern
bool
SetConsoleMode
(
IntPtr
hConsoleHandle
,
uint
dwMode
);
internal
static
bool
DisableQuickEditMode
()
{
IntPtr
consoleHandle
=
GetStdHandle
(
STD_INPUT_HANDLE
);
// get current console mode
uint
consoleMode
;
if
(!
GetConsoleMode
(
consoleHandle
,
out
consoleMode
))
{
// ERROR: Unable to get console mode.
return
false
;
}
// Clear the quick edit bit in the mode flags
consoleMode
&=
~
ENABLE_QUICK_EDIT
;
// set the new mode
if
(!
SetConsoleMode
(
consoleHandle
,
consoleMode
))
{
// ERROR: Unable to set console mode
return
false
;
}
return
true
;
}
}
}
Examples/Titanium.Web.Proxy.Examples.Basic/Program.cs
View file @
d8ba1b88
using
System
;
using
System
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Titanium.Web.Proxy.Examples.Basic.Helpers
;
namespace
Titanium.Web.Proxy.Examples.Basic
namespace
Titanium.Web.Proxy.Examples.Basic
{
{
...
@@ -11,8 +12,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -11,8 +12,7 @@ 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
//fix console hang due to QuickEdit mode
var
handle
=
Process
.
GetCurrentProcess
().
MainWindowHandle
;
ConsoleHelper
.
DisableQuickEditMode
();
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
;
...
@@ -46,8 +46,6 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -46,8 +46,6 @@ 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
;
...
@@ -57,7 +55,6 @@ namespace Titanium.Web.Proxy.Examples.Basic
...
@@ -57,7 +55,6 @@ 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
);
}
}
}
}
Examples/Titanium.Web.Proxy.Examples.Basic/Titanium.Web.Proxy.Examples.Basic.csproj
View file @
d8ba1b88
...
@@ -55,6 +55,7 @@
...
@@ -55,6 +55,7 @@
<Reference
Include=
"System.Xml"
/>
<Reference
Include=
"System.Xml"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Helpers\ConsoleHelper.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"ProxyTestController.cs"
/>
<Compile
Include=
"ProxyTestController.cs"
/>
...
...
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