473,750 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows Form application Timer Tick

4 New Member
Hi!

I use C# 4.0 to build a windows form application.
I have a Windows Forms Timer that should tick every second. In every tick I do some work (get GPS position, update a map, save to a local DB etc). It takes about 0.09 sec to execute. The save to the local DB is done async to release the GUI thread faster but the other code is executed on the GUI thread (need to for updating the GUI)

Some time the tick is not fired constantly, it can be several seconds between (I guess the GUI thread is busy in some way).

How can I rewrite so that there always will be a tick on time, is it possible? The program runs on machine with a single processor. Most of the time the CPU usage is not very high.

Would there be any meaning to switch to a System.Threadin g Timer to get more accuracy? I do need to be on the GUI thread most of the time during the Timer execution.

Regards
Henrik
Feb 21 '11 #1
5 4138
GaryTexmo
1,501 Recognized Expert Top Contributor
I'd recommend looking into threading or a background worker for this. When your timer ticks, create a thread to handle your update. You can have attach an event to when it's finished so that your GUI can do anything else it needs to when that's finished.

I notice you said you are doing this asynchronously so perhaps you already know about this. I figured I'd mention it anyway :)

What I'm curious about is why your timer doesn't tick on time. You've got it to tick every second and that's plenty of time for you to get your calculations done. So if it's not ticking on time, there's something else going on here. What would be preventing the timing, especially since your work is getting done asynchronously?

Is the GUI update taking longer than your 1 second tick window?
Feb 22 '11 #2
Henrik Söderber
4 New Member
The GUI update should be much faster than 1 second. but since there are other software involved (3:part) updating the GUI, its hard to know how much time and power it takes.

But something is taking time, I have tried to do as much as possible in other threads (async).
Feb 24 '11 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
Have you considered having separate timers for your GUI update and your logic updates?
Feb 24 '11 #4
Henrik Söderber
4 New Member
Yes, I have considered many different solutions. I do think that the GUI update must be tight connected to the other updates for it to be real-time feeling for the user...
Feb 25 '11 #5
GaryTexmo
1,501 Recognized Expert Top Contributor
I don't know that's not always true. Where I'm coming from is a gaming standpoint. Often, a game's update loop happens more often than the display loop. Really, the human eye/brain can only comprehend information so quickly so it makes a bit of sense. The display method doesn't generate/process any new information, it only displays graphically the current state of the information.

I'm just throwing this out there for you to consider. If you can't do this in your program, you can't. At some point though, if your updates/display are taking longer than your time slice you'll either have to expand your time slice or do less work in each time slice. You can accomplish the latter by either reducing the complexity of your code, or performing some tasks in alternating time slices.
Feb 25 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1645
by: David | last post by:
So I'm a new user to Visual Studio .NET. I'm having a problem with an initial setup of a Windows Form Application for a Visual C++ Project. The Windows Form Application (.NET) template is not shown. Any ideas or suggestions of why? I'm pretty sure its not an installation problem because I did a full installation of Visual Studio .Net Professional.
0
2529
by: forge | last post by:
Installing Merge Modules from C# Windows Form Application (not using a setup and deployment project) Hi, Currently, we have an InstallShield project that creates a setup.exe that only installs 20 or so merge modules. It does nothing else. We then have our own custom, C# Windows Form application that installs our software applications. It does this by copying files, creating registry keys, etc.
1
2201
by: Dean R. Henderson | last post by:
I have a Windows library that I bind into a Windows Form application and into an ASP.NET Web Application. I have a procedure in the library that executes a DTS Package. I have also used information from Knowledge Base article 306158, INFO: Implementing Impersonation in an ASP.NET Application to create a procedure to perform impersonation. When I try to execute the DTS Package from ASP.NET, I get the following error: Step...
4
7088
by: bob lambert | last post by:
Help I am trying to deploy to another pc a vb.net std 2002 windows form application. I am confused. I created a project - windows form I built form, compiled and debugged. I created a deployment project (myproj installer) I added my windows app to the installer under myproj installer properties, I set bootstrapper
3
2975
by: Henry Seymour | last post by:
I've developed a .Net Windows Form application and used the Click-Once Deployment. In that application I would like to allow the user a click-once method of uninstalling it. I do not find an uninstall folder for this application. How can I programmatically uninstall the application? Perferred language is Visual Basic.
1
2235
by: Dave | last post by:
Hello all, I have an application that is accessing files from a mapped drive. I have full access to the share that is mapped and from explorer can delete files as I need. My application needs to be able to delete files once the are processed, but using File.Delete does not seem to be deleting them. What is the correct way of deleting files from a network drive in Windows.Form application?
0
1277
by: querry | last post by:
Hi all, I am developing a Windows form Application in VC++.NET using the Visual Studio 2005 installed on Windows Server 2003. The UI part of the project is almost complete. I am now looking forward to implement the core functionality of the project. This project was originally written in MFC. I do not know much about MFC and I have not programmed in MFC. I want to use the exesting MFC implemented functionality in my Windows Form Application. Is...
2
2603
by: ashkan0021 | last post by:
hi, i have a solution in C#.Net that includes 2 project and ASP.net & A Windows form application project, i want to open some pages of my asp.net project in my windows application, i'd be realy appricite for your help!
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9339
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4713
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.