2
我喜歡在Windows Forms項目中使用Sleep()函數,但Sleep()在其他任何操作之前執行。我讀過我應該使用fflush()刷新,但我不知道要刷新什麼。有人能幫我嗎?Visual Studio 2010 C++ Sleep()
的代碼:
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++語法。 – imi007