【发布时间】:2012-12-17 05:41:45
【问题描述】:
我喜欢在 Windows 窗体项目中使用 Sleep() 函数,但 Sleep() 会在其他任何操作之前执行。我读到我应该使用 fflush() 刷新,但我不知道要刷新什么。有人可以帮我吗?
代码:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->label1->Visible= false;
this->button1->Visible= false;
r = (float)rand()/(float)RAND_MAX;
r = r*100000;
i = r;
r = r - i;
String^ strR = "" + r;
this->label2->Text = strR;
if(r >= 0.5)
{
this->pictureBox1->Visible= true;
this->pictureBox1->BackColor = System::Drawing::Color::Blue;
}
else
{
this->pictureBox1->Visible= true;
this->pictureBox1->BackColor = System::Drawing::Color::Red;
}
Sleep(500);
}
【问题讨论】:
-
一个问题:为什么你用 c++-cli 编程,而写 c# 会更安全?
-
我只知道c++语法。
标签: c++ winforms visual-studio-2010 sleep