Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

System.Windows.Forms.Timer on Windows Services

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kürþat - 21 Aug 2006 09:07 GMT
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.
Vadym Stetsyak - 21 Aug 2006 09:41 GMT
Hello, KЭrЧat!

K> I use System.Windows.Forms.Timer with a Windows service but nothing
K> happens after given interval elapsed.  It seems timer event does not
K> occur. 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
Kursat - 21 Aug 2006 10:56 GMT
Thanks Vadym, worked well.

> Hello, Kürþat!
>
[quoted text clipped - 12 lines]
> Regards, Vadym Stetsyak
> www: http://vadmyst.blogspot.com
Marc Gravell - 21 Aug 2006 09:45 GMT
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
Kürsat - 21 Aug 2006 10:59 GMT
Synchronization requirement is a good point to care about. Thank you.

>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
[quoted text clipped - 8 lines]
>
> Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.