+ Reply to Thread
Results 1 to 2 of 2

Thread: Timer in C#

  1. #1

    Timer in C#

    List consist of collection of string say 5 or 6 at a time. Now, I want to display string one on label1 and it should wait for 5s and then display string 2 on label1. I have timer control and I am specifying my code in timer_tick event.
    Code:
         private void timer1_Tick(object sender, EventArgs e)
        {
            string[] myStatus = myStatusCollection.ToArray();
            int length = myStatus.Length;
    
            for (int i = 0; i < length; i++)
            {
                string _myStatus = myStatus[i];
                MessageBox.Show("Twitter Status =" + _myStatus);
            }
    
        }

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    31
    You need to use that code :
    Code:
    public class Form1 : Form
       {
    
        private string[] statuses = { "A", "B", "C", "D", "E" };
        private int index = 0;
    
       private void OnTimerTick(object sender, EventArgs e) 
           {
            string status = statuses[index];
    
            index++;
    
            if (index == statuses.Length)
            {
                index = 0;
            }
        }
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts