各位大大好,小弟目前在用Vc++寫表單程式,但目前有一個項目是按下start讓顏色按照順
序間隔一秒出現例如:
color1
=> color2
=> color3
=> color4
=> color5
=> color6
start_click出來的程式碼如下:
int i,n=100000000;
01 private: System::Void startbutton_Click(System::Object^ sender,
02 System::EventArgs^ e) {
03 color1->Visible = true;
04 for (i = 1; i <= n; i++);
05 color1->Visible = false;
06 color2->Visible = true;
07 for (i = 1; i <= n; i++);
08 color2->Visible = false;
09 color3->Visible = true;
10 for (i = 1; i <= n; i++);
11 color3->Visible = false;
12 color4->Visible = true;
13 for (i = 1; i <= n; i++);
14 color4->Visible = false;
15 color5->Visible = true;
16 for (i = 1; i <= n; i++);
17 color5->Visible = false;
18 color6->Visible = true;
19 for (i = 1; i <= n; i++);
20 color6->Visible = false;
21 }
程式可以compile,但是按下後並不會出現,如果把Visible=false註解掉,會發現她要過
了6秒後才會一起出現,如果把for迴圈改成 System::Threading::Thread::sleep(n)
/n=1000 ,仍然無法是這種情況,想請各位大大幫忙看看。不好意思,因為在網路上找不
太到如何debug,所以可能要麻煩各位大大了。