I'm running a socket server on my server and I woke up to messages about its inaccessibility. It turns out that before I went to bed, I had selected text in the window. I forgot to hit Enter to resume the process.
This is how I disable selection in the console, now, but I still want to be able to select without the application pausing.
#region Disable Quick-Edit Mode
[DllImport("kernel32.dll")]
static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode);
[DllImport("kernel32.dll")]
static extern bool GetConsoleMode(IntPtr hConsoleHandle, out int mode);
[DllImport("kernel32.dll")]
static extern IntPtr GetStdHandle(int handle);
const int STD_INPUT_HANDLE = -10;
const int ENABLE_EXTENDED_FLAGS = 0x80;
public static void DisableQuickEditMode()
{
int mode;
IntPtr handle = GetStdHandle(STD_INPUT_HANDLE);
GetConsoleMode(handle, out mode);
mode |= ENABLE_EXTENDED_FLAGS;
SetConsoleMode(handle, mode);
mode &= ~ENABLE_QUICK_EDIT;
SetConsoleMode(handle, mode);
}
I really don't want to go back to the Legacy Mode of Command Prompt, because it really does help to have the new console features, but I need to find a way to prevent the application from stopping when I pause the console.
What's interesting is that when I hit Enter this morning, all of the connections that had been attempted were accepted, and then after they were un-queued, they were dropped. Which makes me wonder if, perhaps, I'm writing the application wrong; that I need to have a "Console" thread and a "Server" thread. I'm not sure that could even make a difference.
Console.WriteLine()
from completing, because the output buffer is full. This question has nothing to do with programming; it's a basic WIndows user topic. – Sporran