[英]C# Mono Console.ReadLine quitting
I am building an application with MONO (C#) on linux mint 14 but i have some issues. 我在Linux Mint 14上使用MONO(C#)构建应用程序,但是我遇到了一些问题。 I have enabled external console in the options and while debugging it's working quite well but after deploying ( openning the .exe in debug folder) the application quits immediately after the Console.ReadLine(); 我已经在选项中启用了外部控制台,并且在调试时可以正常工作,但是在部署(在调试文件夹中打开.exe)之后,应用程序在Console.ReadLine()之后立即退出。 Any ideas guys ? 有什么想法吗?
public static void InitializeUI()
{
Console.WriteLine("On the bottom line enter the command \"START\" followed by a space and a number representing on how many hours to check for new posts. You can always stop the execution with Ctrl+C \r\n \r\nExample : START 6");
ParseCMD();
Console.ReadLine ();
}
private static void ParseCMD()
{
string cmd = Console.ReadLine();
string[] commands = cmd.Trim().Split(new string[] {" "},StringSplitOptions.RemoveEmptyEntries);
int delay = 0;
if (commands[0].ToLower() == "start" && int.TryParse(commands[1],out delay))
{
MainLogic.StartLogic(delay);
}
else
{
Console.WriteLine("Wrong command");
ParseCMD();
}
}
quits after the 退出后
string cmd = Console.ReadLine();
public static void Main(string[] args)
{
Console.WriteLine("On the bottom line enter the command \"START\" followed by a space and a number representing on how many hours to check for new posts. You can always stop the execution with Ctrl+C \r\n \r\nExample : START 6");
if(!ParseCMD(readKeey()))
{
ParseCMD(readKeey());
}
}private static string readKeey()
{
ConsoleKeyInfo cki;
Console.TreatControlCAsInput = true;
string temp="";
do
{
cki = Console.ReadKey();
temp=temp+cki.KeyChar;
} while (cki.Key != ConsoleKey.Enter);
return temp;
}
private static bool ParseCMD(string text)
{
try{
string cmd = text;
string[] commands = cmd.Trim().Split(new string[] {" "},StringSplitOptions.RemoveEmptyEntries);
int delay = 0;
if (commands[0].ToLower() == "start" && int.TryParse(commands[1],out delay))
{
Console.WriteLine("Right command you enter:" + commands[0] + commands[1]);
return true;
}
else
{
Console.WriteLine("Wrong command");
return false;
}
}
catch(Exception ex)
{
Console.WriteLine("ex.Message:"+ex.Message);
return false;
}
}
}}
I guess it is nothing about Mono, could you please try Console.ReadKey() instead. 我想这与Mono无关,请您改用Console.ReadKey()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.