Click here to Skip to main content
15,890,185 members
Home / Discussions / C#
   

C#

 
GeneralRe: Disaplying different panels from options in a dropdown list Pin
AdamskiR11-Oct-05 22:55
AdamskiR11-Oct-05 22:55 
GeneralRe: Disaplying different panels from options in a dropdown list Pin
XRaheemX12-Oct-05 3:52
XRaheemX12-Oct-05 3:52 
QuestionButton Event Handler Pin
Brendan Vogt11-Oct-05 3:27
Brendan Vogt11-Oct-05 3:27 
AnswerRe: Button Event Handler Pin
XRaheemX11-Oct-05 3:40
XRaheemX11-Oct-05 3:40 
GeneralRe: Button Event Handler Pin
Brendan Vogt11-Oct-05 4:34
Brendan Vogt11-Oct-05 4:34 
GeneralRe: Button Event Handler Pin
XRaheemX11-Oct-05 4:47
XRaheemX11-Oct-05 4:47 
QuestionWait in loop Pin
mrnoname11-Oct-05 3:16
mrnoname11-Oct-05 3:16 
AnswerRe: Wait in loop Pin
XRaheemX11-Oct-05 3:29
XRaheemX11-Oct-05 3:29 
System.Threading.Thread.Sleep will sleep the entire thread for x milliseconds before continuing. Keep in mind that if this code is running in your form, the form will not respond to any windows command for that 3 seconds. If you want this to work properly, you should run this block of code in a new thread.


One other way to do this (without locking up the form) is to create a timer instead of a loop.
See the code below:


<code>
   private int currentPlayer = 0;
   private System.Windows.Forms.Timer t = new Timer();
   
   public void BeginSetupCards()
   {
      this.t.Interval = 3000; //this is 3 seconds (in milliseconds)
      this.t.Tick += new EventHandler(t_Tick); //Set up the "tick" method
   }

   private void t_Tick(object sender, EventArgs e)
   {
      // Do something 
      // use this.currentPlayer for the current player ID
      // Update the view
      updateview(); // It's a bad idea to update the form view from within a timer.  You should create an event delegate for the update and kick it off using Form.Invoke;
      
      this.currentPlayer++; // Add one to the current id
      if(this.currentPlayer >= (this.players.Length * 2))
      { 
         this.t.Stop();  //Stop this when done
      }

      //Now this code block will run every 3 seconds
   }
</code>


Keep in mind that there are much better ways of doing this (which are a little more advanced) such as custom threading or even better asynchronous methods. If you would like some examples of the more advanced methods, please reply and I'll be glad to show you.
GeneralRe: Wait in loop Pin
S. Senthil Kumar11-Oct-05 4:20
S. Senthil Kumar11-Oct-05 4:20 
GeneralRe: Wait in loop Pin
XRaheemX11-Oct-05 4:39
XRaheemX11-Oct-05 4:39 
GeneralRe: Wait in loop Pin
mrnoname11-Oct-05 9:25
mrnoname11-Oct-05 9:25 
AnswerRe: Wait in loop Pin
Wjousts11-Oct-05 4:22
Wjousts11-Oct-05 4:22 
GeneralRe: Wait in loop Pin
XRaheemX11-Oct-05 4:42
XRaheemX11-Oct-05 4:42 
GeneralRe: Wait in loop Pin
Wjousts11-Oct-05 6:46
Wjousts11-Oct-05 6:46 
GeneralRe: Wait in loop Pin
XRaheemX11-Oct-05 7:10
XRaheemX11-Oct-05 7:10 
QuestionVB.NET IRR Function Pin
zaboboa11-Oct-05 3:04
zaboboa11-Oct-05 3:04 
AnswerRe: VB.NET IRR Function Pin
Dave Kreskowiak11-Oct-05 5:38
mveDave Kreskowiak11-Oct-05 5:38 
GeneralRe: VB.NET IRR Function Pin
zaboboa11-Oct-05 9:45
zaboboa11-Oct-05 9:45 
QuestionWindows Service Pin
Talktorajeev11-Oct-05 2:20
Talktorajeev11-Oct-05 2:20 
AnswerRe: Windows Service Pin
XRaheemX11-Oct-05 3:18
XRaheemX11-Oct-05 3:18 
QuestionIs there any API for powerpoint file programming in .net? Pin
ting66811-Oct-05 2:18
ting66811-Oct-05 2:18 
AnswerRe: Is there any API for powerpoint file programming in .net? Pin
David Stone11-Oct-05 7:26
sitebuilderDavid Stone11-Oct-05 7:26 
GeneralRe: Is there any API for powerpoint file programming in .net? Pin
ting66812-Oct-05 1:50
ting66812-Oct-05 1:50 
QuestionStarter KIT Problem Pin
Micu Radu11-Oct-05 1:59
Micu Radu11-Oct-05 1:59 
QuestionOffice Development BIG PROBLEM Pin
Micu Radu11-Oct-05 1:59
Micu Radu11-Oct-05 1:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.