[C#] C#解冻Windows UI界面的方法 →→→→→进入此内容的聊天室

来自 , 2020-10-16, 写在 C#, 查看 159 次.
URL http://www.code666.cn/view/5cb0e249
  1. // You need the Threading library to use the
  2. // "Thread.Sleep" function
  3. // using System.Threading;
  4.  
  5. // This boolean value can be used to stop the
  6. // process below
  7. bool UserHitCancel = false;
  8.  
  9. this.progressBar.Maximum = 100;
  10.  
  11. // Loop 100 times
  12. for (int i = 0; (i < 100 && !UserHitCancel); i++)
  13. {
  14.     // Update a progressbar or any other control
  15.     this.progressBar.Value = i;
  16.  
  17.     // This function checks if the user fired any
  18.     // events, like clicks on a cancel button and
  19.     // allowes the application to react
  20.     Application.DoEvents();
  21.  
  22.     // This tells the current thread to sleep for 50 milliseconds,
  23.     // so that the user can see the progress bar filling up
  24.     Thread.Sleep(TimeSpan.FromMilliseconds(50));
  25. }
  26. //csharp/2054

回复 "C#解冻Windows UI界面的方法"

这儿你可以回复上面这条便签

captcha