473,385 Members | 1,876 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,385 software developers and data experts.

System.Windows.Forms.Timer on Windows Services

Hi all,

I use System.Windows.Forms.Timer with a Windows service but nothing happens
after given interval elapsed. It seems timer event does not occur. How can
I use timers with Windows Services?

Thanks in advance.

Aug 21 '06 #1
4 3156
Hello, Kürşat!

KI use System.Windows.Forms.Timer with a Windows service but nothing
Khappens after given interval elapsed. It seems timer event does not
Koccur. How can I use timers with Windows Services?

Take a look in System.Timers.Timer class. or
System.Threading.Timer class

In your case System.Windows.Forms.Timer is not working, because you do not
have message loop and this type of timer uses WM_TIMER windows message
to operate...

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Aug 21 '06 #2
I must adimit I've never tried to use winform timers in a service, so I
can't say if it is possible - *but* you could perhaps switch to
System.Timers.Timer? Just watch out that the Elapsed event is fired on
a different thread, so you may need to do your own thread sync code.
And note that you will need to kill the timer yourself at the end, as
there is no form to host it and manage its lifetime (although I /guess/
you could just let it get torn down at AppDomain unload, but I like to
be tidy ;-p).

Any use?

Marc

Aug 21 '06 #3
Thanks Vadym, worked well.

"Vadym Stetsyak" <va*****@ukr.netwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello, Kürşat!

KI use System.Windows.Forms.Timer with a Windows service but nothing
Khappens after given interval elapsed. It seems timer event does not
Koccur. How can I use timers with Windows Services?

Take a look in System.Timers.Timer class. or
System.Threading.Timer class

In your case System.Windows.Forms.Timer is not working, because you do not
have message loop and this type of timer uses WM_TIMER windows message
to operate...

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Aug 21 '06 #4
Synchronization requirement is a good point to care about. Thank you.

"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>I must adimit I've never tried to use winform timers in a service, so I
can't say if it is possible - *but* you could perhaps switch to
System.Timers.Timer? Just watch out that the Elapsed event is fired on
a different thread, so you may need to do your own thread sync code.
And note that you will need to kill the timer yourself at the end, as
there is no form to host it and manage its lifetime (although I /guess/
you could just let it get torn down at AppDomain unload, but I like to
be tidy ;-p).

Any use?

Marc

Aug 21 '06 #5

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

Similar topics

4
by: Bilo | last post by:
I have a Windows Forms Class MainGUI I have declared MainGUI maingui; public System.ComponentModel.Container components = new Container(); in the Class I call another class MediaDriver with...
0
by: Claire | last post by:
I'm using a System.Windows.Forms.Timer object to poll a comms port. If the poll finds a device attached to the other end, a form is created, some configuration files are loaded and the form is left...
2
by: Chris Dunaway | last post by:
I am attempting to use the AppDomain.UnhandledException event in a Windows Forms app and also in a Windows Service. But the event doesn't seem to be called. In a Windows Forms app, the event IS...
4
by: Philip Wagenaar | last post by:
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...
1
by: Gianmaria | last post by:
Hi, i've wrote a windows service that handle incoming tcp connections. Now i need to let him communicate with a windows form.. but without remoting. My service fires events too that i subscribe in...
0
by: dipalichavan82 | last post by:
i created windows service with timer in which i m deleting files of specific extensions on client m/c n putting on server .i m taking values for 1.list of file extensions dat should be considerd...
0
by: Nemisis | last post by:
Hi everyone, I believe this is possible as i think this is how anti-virus works, i have created a windows service with a couple public readonly properties and i would like to read these...
4
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i have a main thread an another worker thread. The main Thread creates another thread and waits for the threads signal to continue the main thread. Everything works inside a ModalDialog and...
8
by: Rainer Queck | last post by:
Hello NG, in my application I have a Panel, docked right to my Form. On this panel I draw - cyclic triggered by a System.Winforms.Timer - a bitmap using the Graphics class. using (Graphics g =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.