Main方法挂个线程,你才可以干其他事
//创建线程,线程调用方法ConsoleWriteStart
Thread t1 = new Thread(new ThreadStart(ConsoleWriteStart));
t1.IsBackground = true;
t1.Start();
动画效果代码
//清行处理操作
//控制台动画效果
int currentLineCursor = Console.CursorTop;//记录当前光标位置
for (int i = 0; ; i++)
{
Console.SetCursorPosition(0, Console.CursorTop);//将光标至于当前行的开始位置
Console.Write(new string(' ', Console.WindowWidth));//用空格将当前行填满,相当于清除当前行
Console.SetCursorPosition(0, currentLineCursor);//将光标恢复至开始时的位置
Console.Write("生成中");
Thread.Sleep(100);//延时100毫秒
Console.SetCursorPosition(0, Console.CursorTop);//将光标至于当前行的开始位置
Console.Write(new string(' ', Console.WindowWidth));//用空格将当前行填满,相当于清除当前行
Console.SetCursorPosition(0, currentLineCursor);//将光标恢复至开始时的位置
Console.Write("生成中.");
Thread.Sleep(100);
Console.SetCursorPosition(0, Console.CursorTop);//将光标至于当前行的开始位置
Console.Write(new string(' ', Console.WindowWidth));//用空格将当前行填满,相当于清除当前行
Console.SetCursorPosition(0, currentLineCursor);//将光标恢复至开始时的位置
Console.Write("生成中..");
Thread.Sleep(100);
Console.SetCursorPosition(0, Console.CursorTop);//将光标至于当前行的开始位置
Console.Write(new string(' ', Console.WindowWidth));//用空格将当前行填满,相当于清除当前行
Console.SetCursorPosition(0, currentLineCursor);//将光标恢复至开始时的位置
Console.Write("生成中...");
Thread.Sleep(100);
Console.SetCursorPosition(0, Console.CursorTop);//将光标至于当前行的开始位置
Console.Write(new string(' ', Console.WindowWidth));//用空格将当前行填满,相当于清除当前行
Console.SetCursorPosition(0, currentLineCursor);//将光标恢复至开始时的位置
Console.Write("生成中....");
}