| | |
Auto Run Procedures in Windows Application
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2006
Posts: 8
Reputation:
Solved Threads: 0
Hi,
I'm sitting with a weird problem.
I created an application in C# 2005 Express. It has 3 timer controls in it.
The first timer runs as a clock (system clock) and once this timer reaches a specific time during the day it runs its procedure (this works fine)
The 2nd timer has its Interval set to 10min. So every 10 minutes it needs to run its procedure.(doesn't do it)
The 3rd timer has its Interval set to 10Sec. So every 10 second it needs to run its two procedures (doesn't do it either);
Now when i run this app in debug mode everything works perfect. Breakpoints are being reached all the time, I don't see any problems. But once i publish the app and install it on a users machine it doesn't always run the procedures :/
As u probably realized is that this application is an auto update app which auto updates data (retrieve data from webservice then update the local SQL database)
Any help would be greatly appreciated. I need to get this working by midday tomorrow.
Any other suggestions would be great.
Thanks
I'm sitting with a weird problem.
I created an application in C# 2005 Express. It has 3 timer controls in it.
The first timer runs as a clock (system clock) and once this timer reaches a specific time during the day it runs its procedure (this works fine)
The 2nd timer has its Interval set to 10min. So every 10 minutes it needs to run its procedure.(doesn't do it)
The 3rd timer has its Interval set to 10Sec. So every 10 second it needs to run its two procedures (doesn't do it either);
Now when i run this app in debug mode everything works perfect. Breakpoints are being reached all the time, I don't see any problems. But once i publish the app and install it on a users machine it doesn't always run the procedures :/
As u probably realized is that this application is an auto update app which auto updates data (retrieve data from webservice then update the local SQL database)
Any help would be greatly appreciated. I need to get this working by midday tomorrow.
Any other suggestions would be great.
Thanks
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
Sounds like a Timing issue <no pun intended>
First I dislike the use of timers for the very reason you have stated. Instead I prefer to use threads... but that is just me.
I suggest that you use the single timer to do all the work since it is all in the main thread anyway. Setup some TimeSpan vars to determine when an action should occur, and let the single timer act on it.
Jerry
First I dislike the use of timers for the very reason you have stated. Instead I prefer to use threads... but that is just me.
I suggest that you use the single timer to do all the work since it is all in the main thread anyway. Setup some TimeSpan vars to determine when an action should occur, and let the single timer act on it.
Jerry
•
•
Join Date: Jan 2006
Posts: 8
Reputation:
Solved Threads: 0
I found the problem, the interval settings were wrong lol.
Sounds good could u maybe give me an example or help on how to do this?
One procedure needs to run a certain time of day (this could change to different times), 2nd procedure should run every 10 seconds and 3rd should run every 10 minutes.
Thanks
•
•
•
•
I suggest that you use the single timer to do all the work since it is all in the main thread anyway. Setup some TimeSpan vars to determine when an action should occur, and let the single timer act on it.
Jerry
One procedure needs to run a certain time of day (this could change to different times), 2nd procedure should run every 10 seconds and 3rd should run every 10 minutes.
Thanks
•
•
Join Date: Nov 2006
Posts: 436
Reputation:
Solved Threads: 72
Pretty straight forward. Some vars for holding the amount of time. You can adjust these as needed in and reset the TimeSpan vars.
In the Tick event handler, evaluate if it is time to run that task, and then reset its Last time ran var.
You can also get creative and call those tasks as a new thread so that the timer can service the other tasks without waiting.
In the Tick event handler, evaluate if it is time to run that task, and then reset its Last time ran var.
You can also get creative and call those tasks as a new thread so that the timer can service the other tasks without waiting.
C# Syntax (Toggle Plain Text)
int Task1Timeout = 10; // seconds int Task2Timeout = 10; // minutes DateTime LastTask1 = DateTime.Now; DateTime LastTask2 = DateTime.Now; TimeSpan timerTask1 = new TimeSpan(0, 0, Task1Timeout); TimeSpan timerTask2 = new TimeSpan(0,Task2Timeout,0); //// _Tick(..) if( DateTime.Now - LastTask1 >= timerTask1) { DoTask1(); LastTask1 = DateTime.Now; } if( DateTime.Now - LastTask2 >= timerTask2) { DoTask2(); LastTask2 = DateTime.Now; }
![]() |
Similar Threads
- Trouble with connecting IE, hotmail, msn messenger, anti-virus sites - help needed (Viruses, Spyware and other Nasties)
- yupsearch bar, plz help me remove!! (hijack this log) (Viruses, Spyware and other Nasties)
Other Threads in the C# Forum
- Previous Thread: How to set the focus on a text box..?
- Next Thread: switch condition
| Thread Tools | Search this Thread |
.net access algorithm alignment array barchart bitmap box broadcast buttons c# c#gridviewcolumn check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing elevated encryption enum event excel file focus forloop form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





