473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stop System.Timer

I have a Queue that contains filenames.
I have a System.Timer with it's interval set to 200.

I load the Queue up with 35.000 files. I start the Timer.

On Timer.Elapsed I take a file from the Queue (.dequeue) and do my business
logic on it.

I use a Windows Forms to control all this. Start button to start the timer
and a Stop button to stop the timer.

But when I press the stop button the application keeps on processing files
in Queue. The time to process a file takes longer then the 200 ms that the
timer is set to. Is this the cause of file processing keeps on going?
Timer.Elapsed has been triggered so many times that the application processes
those even though I have stopped the timer?

How can I stop the processing? By checking in my business logic code if the
timer is enables or not? Is this a 'clean' way to solve this all?
Nov 21 '05 #1
4 1852
Philip,

As question first is there a reason that you do not handle the
windows.forms.timer, that one runs on the same thread?

Cor
Nov 21 '05 #2
The application is now running as a windows application. Once this works 100%
I want to change it to run as a service and only use a windows forms for
configuring settings. That is why I choose system.timer instead of the
windows forms timer.

Is there a big diffrence between the two? Instead of the thread it runs in?
Nov 21 '05 #3
Philip,

Is there a big diffrence between the two? Instead of the thread it runs
in?


Yes the forms timer does only run in relation to a form

:-)

Cor
Nov 21 '05 #4
"Philip Wagenaar" <ph*************@online.nospam> schrieb:
I have a Queue that contains filenames.
I have a System.Timer with it's interval set to 200.

I load the Queue up with 35.000 files. I start the Timer.

On Timer.Elapsed I take a file from the Queue (.dequeue) and do my
business
logic on it.

I use a Windows Forms to control all this. Start button to start the timer
and a Stop button to stop the timer.


I am curious why you are using a timer at all and which of the timer classes
available in the .NET Framework's class library you are using.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Geoff | last post by:
Hey.. I'm having problems with stopping this timer from outside the 'runTimer()' class.. i have no problems calling 'cancel()' from inside the run() method but I want to be able to stop the Timer...
1
by: Chua Wen Ching | last post by:
Hi there. I am displaying a string which will appear 1 char at a time. The problem is after it display the 1st string, it will keep on continue. When i uncomment the myTimer.stop(), it does...
2
by: User | last post by:
Hi, What is the best way to release all resources holded by the Timer (myTimer from class System.Timers.Timer)? Is it: 1- myTimer.dispose 2- myTimer.enabled = false 3- myTimer.close
6
by: Xero | last post by:
Hi. I have created a 'stop watch' program. The working principle of the program is to declare an integer (say 'intTime'), which is initalized to zero. Once the user clicks the 'Start' button,...
3
by: Tom | last post by:
When using system.timers.timer, which should one use to start/stop the timer? Start/Stop, or Enabled=True/False? If what I read is true, both really do the same thing, so I don't know if there is...
6
by: Michael C | last post by:
I've created a timer object and set it running without keeping a reference to it and not stopping it. Shouldn't the garbage collector pick up that there's no reference to the timer, call finalize...
4
by: Boki | last post by:
Hi All, I have a timer, if my data queue Q has data, the timer should start work, if there is no data in Q, the timer should stop. However, there is an event can fire timer to start. Should I...
5
by: =?Utf-8?B?Sm9uYXRoYW4gU21pdGg=?= | last post by:
I have written a service, but it won't stop, Eventvwr reports the following: "Failed to stop service" The code is as follows: ============================================ Protected Overrides...
7
by: Daniele Piccinini | last post by:
Hallo, I've writed a C# windows service in VS 2003. This service use a System.Timers.Timer to periodically call some functions of a web service. ( Some of this functions required minutes to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.