小编imi*_*007的帖子

Visual Studio 2010 c ++ Sleep()

我喜欢在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);

         }
Run Code Online (Sandbox Code Playgroud)

c++ sleep visual-studio-2010 winforms

2
推荐指数
1
解决办法
3614
查看次数

标签 统计

c++ ×1

sleep ×1

visual-studio-2010 ×1

winforms ×1