473,756 Members | 3,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timer in a Window Service not "ticking"

I'm trying to create a nifty Windows Service that will perform tasks at a
predetermined interval.

To make sure I understand the timing correctly I have set an emailer utility
to email me on the start and stop of the service...this works fine. However,
I am trying to test the "ticking" of the timer control and have an emailer
in the sub that handles the timer tick, unfortunately it does not appear to
be ticking...

Can anyone tell me what I'm doing wrong here? (Code below)

Thanks Chris,

Protected Overrides Sub OnStart(ByVal args() As String)

' Add code here to start your service. This method should set things

' in motion so your service can do its work.

'load settings xml file

Dim xmlSettings As New XmlDocument()

xmlSettings.Loa d("c:\carrotink \nexus\nexusser vice\settings.x ml")

'set connection string carrot patch node

Dim nodeConnectionS tringCarrotPatc h As XmlNode =
xmlSettings.Doc umentElement.Se lectSingleNode( "./settings/connectionStrin gs/c
arrotPatch")

'set connection string commerce node

Dim nodeConnectionS tringCommerce As XmlNode =
xmlSettings.Doc umentElement.Se lectSingleNode( "./settings/connectionStrin gs/c
ommerce")

'set smtp server node

Dim nodeSMTPServer As XmlNode =
xmlSettings.Doc umentElement.Se lectSingleNode( "./settings/notification/smtpSe
rver")

'set smtp server node

Dim nodeEmailSender As XmlNode =
xmlSettings.Doc umentElement.Se lectSingleNode( "./settings/notification/emailS
ender")

'instantiate settings object

_settings = New NexusService.Se ttings(nodeSMTP Server.InnerTex t,
nodeEmailSender .InnerText, nodeConnectionS tringCarrotPatc h.InnerText,
nodeConnectionS tringCommerce.I nnerText)

'start the timer

timerMain.Inter val = 5000

timerMain.Enabl ed = True

timerMain.Start ()

'send an email that service has started

Dim notifier As New NexusService.No tification(Me.S ettings)

notifier.Email. Notify("chris", "Service - STARTED - " + Now(), "Service -
STARTED at " + Now(), Web.Mail.MailPr iority.Normal)

End Sub

Private Sub timerMain_Tick( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles timerMain.Tick

Dim notifier As New NexusService.No tification(Me.S ettings)

notifier.Email. Notify("chris", "Service RUNNING - " + Now(), "Service -
RUNNING at " + Now(), Web.Mail.MailPr iority.Normal)

End Sub

Protected Overrides Sub OnStop()

' Add code here to perform any tear-down necessary to stop your service.

timerMain.Stop( )

Dim notifier As New NexusService.No tification(Me.S ettings)

notifier.Email. Notify("chris", "STOPPED - " + Now(), "Service - STOPPED at "
+ Now(), Web.Mail.MailPr iority.Normal)

End Sub
Nov 20 '05 #1
3 3285
In article <#w************ **@TK2MSFTNGP12 .phx.gbl>, Chris Hayes wrote:

<snip>

Chris,

Without looking to closely :), it is my guess that your timer is a
System.Windows. Forms.Timer. That will not work without a message pump
on the thread. You will want to use either the System.Timers.T imer or
the System.Threadin g.Timer.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #2
Thanks Tom!

I didn't realize that.

Setting it up as a System.Timers.T imer works like a champ!

I hereby proclaim you a guru.

Thanks again,

Chris
"Tom Shelton" <to*@mtogden.co m> wrote in message
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
In article <#w************ **@TK2MSFTNGP12 .phx.gbl>, Chris Hayes wrote:

<snip>

Chris,

Without looking to closely :), it is my guess that your timer is a
System.Windows. Forms.Timer. That will not work without a message pump
on the thread. You will want to use either the System.Timers.T imer or
the System.Threadin g.Timer.

--
Tom Shelton
MVP [Visual Basic]

Nov 20 '05 #3
"I hereby proclaim you a guru."
(Chris Hayes)
That's nice Tom Shelton... ;-)
"Tom Shelton" <to*@mtogden.co m> escreveu na mensagem
news:Ow******** ******@TK2MSFTN GP09.phx.gbl...
In article <#w************ **@TK2MSFTNGP12 .phx.gbl>, Chris Hayes wrote:

<snip>

Chris,

Without looking to closely :), it is my guess that your timer is a
System.Windows. Forms.Timer. That will not work without a message pump
on the thread. You will want to use either the System.Timers.T imer or
the System.Threadin g.Timer.

--
Tom Shelton
MVP [Visual Basic]

Nov 20 '05 #4

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

Similar topics

8
3377
by: Chul Min Kim | last post by:
Hi, I got a BUS ERROR from one of my company's program. Let me briefly tell our environment. Machine : Sun E3500 (Ultra Sparc II 400Mhz CPU 4EA) OS : Solaris7 Compiler : Sun Workshop 5.0 cc complier I get "BUS ERROR" only when I execute the binary which builds
37
3984
by: jht5945 | last post by:
For example I wrote a function: function Func() { // do something } we can call it like: var obj = new Func(); // call it as a constructor or var result = Func(); // call it as a function
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.