Friday, 20 July 2012

25. Trader can fetch data periodically - C# timer

Trader can fetch data from Internet periodically with period defined in seconds. Button with text "timer Stoped" starts remote data fetching. Period is defined in second in field timinG. After button is clicked text is changed to "timer Started". Button Get live is run every 120 seconds (default value). Also, you'll need  Timer control from Toolbox.

There is code:

 private void timeR_Click(object sender, EventArgs e)
        {
            if (tGetLive.Enabled == false)
            {
                tGetLive.Interval = Convert.ToInt32(timinG.Text)*1000; //60000; - 60 sec
                tGetLive.Start();
                timeR.Text = "Timer started";
            }
            else
            {
                tGetLive.Stop();
                timeR.Text = "Timer stopped";
            }
       }


private void tGetLive_Tick(object sender, EventArgs e)
        {
            getLive.PerformClick();
        }

No comments:

Post a Comment