Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1800 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Other Programming Languages :

C# Running a function every x seconds

Thread title: C# Running a function every x seconds
Reply    
    Thread tools Search this thread Display Modes  
07-19-2010, 02:46 AM
#1
geforce is offline geforce
Status: Member
Join date: Jul 2006
Location: UK
Expertise: Programming - PHP & MySQL
Software: Photoshop and Notepad++
 
Posts: 216
iTrader: 2 / 100%
 

geforce is on a distinguished road

Send a message via AIM to geforce

  Old

I've run the timer in a htread and that did not help either.

Code:
        public static System.Timers.Timer aTimer;

        public void Form1_Load(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(Timer));
        }

        public static void Timer()
        {
            // Create a timer with a three second interval.
            aTimer = new System.Timers.Timer(3000);

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

            // Set the Interval to 2 seconds (2000 milliseconds).
            aTimer.Interval = 2000;
            aTimer.Enabled = true;
        }
I'm not the best C# coder as I hardly use it, so be gentle lol.

Cheers

Reply With Quote
Reply    


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed