我有这两种方法
public void L1Timer()
{
Console.Clear();
int score = tot;
Console.Write("Chances : " + ch);
Console.CursorLeft = 40;
Console.Write("Marks : " + score);
for (int time = 0; time <= 100000; time++)
{
Console.SetCursorPosition(65, 0);
Console.Write("Time Elapsed : " + time + " Secs");
Console.CursorLeft = 40;
stime = time;
Thread.Sleep(1000);
Console.Beep();
//Level1();
}
}
public void Level1()
{
Console.WriteLine("\n\n");
Console.CursorLeft = 40;
Console.WriteLine("C _ _ E _ _ _ T _ _ N");
Console.WriteLine("\n\n");
tot = 0;
while ((tot <= 70) && (ch > 0))
{
Console.Write("Guess : ");
string gues = Console.ReadLine();
switch (gues)
{
case "E": tot += 10; ch--; L1Timer(); Level1(); break;
case "L": tot += 10; ch--; break;
case "B": tot += 10; ch--; break;
case "R": tot += 10; ch--; break;
case "A": tot += 10; ch--; break;
case "I": tot += 10; ch--; break;
case "O": tot += 10; ch--; break;
default: tot += 0; ch--; break;
}
Console.WriteLine();
}
}
我想先执行第一个方法,然后开始执行第二个方法,第一个方法计时器仍在计数,而不会延迟第二个线程......我试过这个
Thread T1 = new Thread(new ThreadStart(L1Timer));
Thread T2 = new Thread(new ThreadStart(Level1));
T1.Start();
T2.Start();
但它没有按我想要的方式工作。它执行了第一个和第二个,但将光标收回到第一个方法,这将不允许用户输入第二种方法并回答问题...请帮助我出去