2个回答
展开全部
这个应该不难吧,帮你写了下,自己看看吧!
class Program
{
private static int rad;//随机数
private static char key;//按键
private static bool sucess=true;//是否输出
static void Main(string[] args)
{
Thread thread = new Thread(OpenCheck);
thread.IsBackground = true;
thread.Start();
Thread thread1 = new Thread(OpenWhile);
thread1.IsBackground = true;
thread1.Start();
thread.Join();
thread1.Join();
}
static void OpenCheck()
{
while (true)
{
var temp = Console.ReadKey();
key = temp.KeyChar;
if (key.Equals('\r'))
{
sucess = false;
}
else if (key.Equals(' '))
{
sucess = true;
}
}
}
static void OpenWhile()
{
Random random = new Random();
while (true)
{
if (sucess)
{
rad = random.Next(100000, 1000000);
Console.WriteLine(rad);
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询