Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

timer on form in vb.net

Posted on 2010-08-23
8
Medium Priority
?
486 Views
Last Modified: 2012-05-10
I have an app that I want to display a timer that updates every second. The problem is that the display hangs while the app is doing database fetches.

Is there a way to make the timer update an independent thread so it is unaffected by the other processes?

Thanks,
0
Comment
Question by:rutledgj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 29

Assisted Solution

by:nffvrxqgrcfqvvc
nffvrxqgrcfqvvc earned 300 total points
ID: 33504199
You will have to use one of the timers that don't associate the forms handle with the timer.

System.Threading.Timer
http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx 
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 33504396
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 33504439
...move your DB operations to a different thread...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rutledgj
ID: 33504493
egl1044: I just tried this but it doesn't seem to work either. It doesn't update the label on the main form.
0
 

Author Comment

by:rutledgj
ID: 33504534
moving dbops to another thread probably isn't an option at this point since the application is basically complete. Just trying to display a timer.

Besides, the timer hangs during logic processing as well as db fetches. I guess I need something completely independent of what the frmMain is doing.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 33504751
Yeah, I only seen you wanted to execute a Timer every second there was no mention of updating  control or label from the timer on the form. The timer should work but your problem is not the timer anymore it's no message can be updated on your form because of your database routine. You will have to use the other experts alternative above so that your form can still process messages to update the controls.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 900 total points
ID: 33504767
"I guess I need something completely independent of what the frmMain is doing."

You can't.  ALL control updates run in the SAME main UI thread.  If frmMain is busy doing DB operations or "logic processing" then it ALSO CANNOT update the current time.

You either need to:
(1) Correctly move processing to another thread.
(2) Pepper your code with "Application.DoEvents()"
0
 

Author Closing Comment

by:rutledgj
ID: 33504787
Since neither solution is feasable without rewriting my code I'll just spread the points to the most logical.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question