■46001 / ) |
Re[1]: Sleepを停止させる方法 |
□投稿者/ みきぬ (735回)-(2010/01/22(Fri) 21:39:17)
|
こういうことがやりたいのかしら。
class Program
{
static bool isBashed = false;
static void Main(string[] args)
{
Console.WriteLine("キーを押すと起こします。");
new Thread(new ThreadStart(sleep)).Start();
Console.ReadKey();
isBashed = true;
Console.ReadLine();
}
static void sleep()
{
for (int i = 0; i < 120; i++)
{
Console.WriteLine("(-_-) {0}", new string('z', (i % 5) + 1));
Thread.Sleep(1000);
if (isBashed) break;
}
Console.WriteLine("Σ(x_x)!");
}
}
|
|