Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2007, 11:02 AM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to n3xt
Default C# 2005 - windows service & timer implemetation

hello.

i create a c# 2005 windows service solution. I want to do something every 10 seconds. I insert timer component. i set all properties to timer. in code in method OnStart() set enabled propertie to true. but timer not working.

how can i run any method every XY seconds??

Thanks

 
Old February 17th, 2007, 12:56 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Are you handling the tick event of the timer in the service?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html

Discussion:
http://p2p.wrox.com/topic.asp?TOPIC_ID=56429
 
Old February 17th, 2007, 01:46 PM
Registered User
 
Join Date: Feb 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to n3xt
Default

Quote:
quote:Originally posted by dparsons
 Are you handling the tick event of the timer in the service?


yes... timer is inserted to service.cs file which is service.
in partial class of this service is line:

this.myTimer.Tick += new System.EventHandler(this.myTimer_Tick);



 
Old March 18th, 2008, 05:18 AM
Registered User
 
Join Date: Mar 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe you could use System.Threading.Timer instead System.Windows.Forms.Timer.
See article http://en.csharp-online.net/Creating...indows_Service for details.

 
Old March 18th, 2008, 02:50 PM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Are you sure the event is firing? Have you called Timer.Start()?

I have just produced a quick proof-of-concept app to just display "TICK" every ten seconds, works fine for me..

Rob
The Developing Developer
Currently Working Towards: MCAD C#
My Blog: http://www.robzyc.spaces.live.com
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
 
Old March 29th, 2008, 08:01 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default

i have similar problem.i have a windows service application.in this application i can write timer results in a text file but i want to close word document if it open.

http://www.youtubeline.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows Service monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 January 3rd, 2009 05:39 PM
Impersonate with windows service for Service A/C vinod_yadav1919 C# 0 October 18th, 2008 02:29 PM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM
Windows Service bmains Pro VB.NET 2002/2003 2 January 21st, 2005 03:21 PM
Web Service & Integrated Windows Authentication TiongLip ASP.NET 1.0 and 1.1 Professional 0 September 17th, 2003 01:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.