111,089
社区成员




while(IsXXX()==false)
{
Thread.Sleep(3000);
}
int counter = 0;
while (isRunning == true)
{
counter++;
Console.WriteLine(counter);
Application.DoEvents();
}
int n = 0;
int counter = 0;
while (isRunning == true)
{
n = Environment.TickCount;
while (Environment.TickCount - n < 3000)
{
counter++;
Console.WriteLine(counter);
Application.DoEvents();
}
}
int n = 0;
while (isRunning == true)
{
n = Environment.TickCount;
while (Environment.TickCount - n < 3000)
{
Console.WriteLine("");
Application.DoEvents();
}
}
int n = 0;
int counter = 0;
while (isRunning == true)
{
//Application.DoEvents();
n = Environment.TickCount;
while (Environment.TickCount - n < 3000)
{
counter++;
Console.WriteLine(counter);
Console.WriteLine(Environment.TickCount);
Application.DoEvents();
}
}
int n = Environment.TickCount;
int counter = 0;
while (Environment.TickCount - n < 3000)
{
counter++;
Application.DoEvents();
}
//Thread.Sleep(3000);
替换为
int n = Environment.Tick;
while(Environment.Tick-n<3000) Application.DoEvents();
while(IsXXX()==false)
{
Application.DoEvents();
}
.....//然后继续干你的事。
private bool m_isLisening = true;
private void button1_Click(object sender, EventArgs e)
{
if (IsDoNext() == true)
{
//执行语句块A
}
else
{
//执行语句块B
}
}
private void button2_Click(object sender, EventArgs e)
{
//切换监听状态
if (m_isLisening == true)
{
m_isLisening = false;
}
else
{
m_isLisening = true;
}
}
private bool IsDoNext()
{
while (IsOK() == false && m_isLisening == true)
{
Thread.Sleep(3000);
}
}
private bool IsOK()
{
if (满足条件)
{
return true;
}
else
{
return false;
}
}