DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Problem with Timers

  1. #1
    Join Date
    Feb 2005
    Posts
    46

    Problem with Timers

    Hi, I have a form (frmForm) with a timer on it, and also an additional class (clsClass.vb). When I run the timer using a button on the form it works fine, but the minute I call a method from my class the timer_click event stops running at the set interval. I've checked and the enabled property is still set to true, but the timer event just no longer runs.

    Also, if I put a msgbox inside the method in clsClass, the timer continues to run until I press 'ok' on the message box. This leaves me to believe that the problem lies when the code returns from the class to the form. Has anyone experienced anything like this?

  2. #2
    Join Date
    Nov 2003
    Posts
    154
    The Windows Forms timer is single-threaded and runs synchronously with other code on the thread; in other words. I suspect that what's happening is that your clsClass code (also running on the same thread, I presume) takes priority and therefore the timer won't fire. The solution is to either start clsClass on a separate thread or use a System.Timers.Timers timer. If you choose to do the latter, read this first: http://msdn.microsoft.com/msdnmag/is...T/default.aspx.
    A. Russell Jones,
    Executive Editor,
    Internet.com

  3. #3
    Join Date
    Feb 2005
    Posts
    46
    Thanks for the reply! I actually changed the timer to a ccrpTimer and it works fine, so I don't know for sure what the problem was, maybe it was the priority of the threads like you said.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center