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

I have a problem with a service I created

Hi,
I created a service to execute every 2 hours but it only executes once at
startup. This is part of the code

Protected Sub Test(ByVal obj As Object)

Dim sDate As String = Date.Today.ToShortDateString

If sDate = "4/25/2005" Then

sEvent = "Test after 10Sec"
oEventLog.WriteEntry(sEvent, EventLogEntryType.Error, 200)

Else

Exit Sub

End If

End Sub

At startup.............

Dim TimerDelegate As New Threading.TimerCallback(AddressOf Test)

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 10000)

Any ideas?
Jul 21 '05 #1
3 1236
Chris,
I think you're missing the leading "0" in the month string you are comparing
in your "if" statement.

Try changing your "if" statement to this:

If sDate = "04/25/2005" Then

HTH,
Jorge

"Chris" wrote:
Hi,
I created a service to execute every 2 hours but it only executes once at
startup. This is part of the code

Protected Sub Test(ByVal obj As Object)

Dim sDate As String = Date.Today.ToShortDateString

If sDate = "4/25/2005" Then

sEvent = "Test after 10Sec"
oEventLog.WriteEntry(sEvent, EventLogEntryType.Error, 200)

Else

Exit Sub

End If

End Sub

At startup.............

Dim TimerDelegate As New Threading.TimerCallback(AddressOf Test)

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 10000)

Any ideas?

Jul 21 '05 #2
Hi,
I did that but still it doesn't work. It works every 5 mins if I set to

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 50000)

but not for an hour or above if set like
Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 3600000 )

Why?


"Jorge L Matos" wrote:
Chris,
I think you're missing the leading "0" in the month string you are comparing
in your "if" statement.

Try changing your "if" statement to this:

If sDate = "04/25/2005" Then

HTH,
Jorge

"Chris" wrote:
Hi,
I created a service to execute every 2 hours but it only executes once at
startup. This is part of the code

Protected Sub Test(ByVal obj As Object)

Dim sDate As String = Date.Today.ToShortDateString

If sDate = "4/25/2005" Then

sEvent = "Test after 10Sec"
oEventLog.WriteEntry(sEvent, EventLogEntryType.Error, 200)

Else

Exit Sub

End If

End Sub

At startup.............

Dim TimerDelegate As New Threading.TimerCallback(AddressOf Test)

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 10000)

Any ideas?

Jul 21 '05 #3
I'm surprised that it works every 5 minutes since it looks like you
configured it fire every 50 seconds (50 sec * 1000 ms = 50,000 ms)

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, 5000, 50000)

I have a suggestion, try debugging your service code, you can either
"Attach" to the process hosting your service or you can develop your service
in a separate class library and instantiate it from a console application. I
prefer to do the latter since I can then unit test the service code.

You can also post the rest of your code for review.

Jorge

"Chris" wrote:
Hi,
I did that but still it doesn't work. It works every 5 mins if I set to

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 50000)

but not for an hour or above if set like
Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 3600000 )

Why?


"Jorge L Matos" wrote:
Chris,
I think you're missing the leading "0" in the month string you are comparing
in your "if" statement.

Try changing your "if" statement to this:

If sDate = "04/25/2005" Then

HTH,
Jorge

"Chris" wrote:
Hi,
I created a service to execute every 2 hours but it only executes once at
startup. This is part of the code

Protected Sub Test(ByVal obj As Object)

Dim sDate As String = Date.Today.ToShortDateString

If sDate = "4/25/2005" Then

sEvent = "Test after 10Sec"
oEventLog.WriteEntry(sEvent, EventLogEntryType.Error, 200)

Else

Exit Sub

End If

End Sub

At startup.............

Dim TimerDelegate As New Threading.TimerCallback(AddressOf Test)

Dim TimerItem As New System.Threading.Timer(TimerDelegate, 1, _
5000, 10000)

Any ideas?

Jul 21 '05 #4

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

Similar topics

0
by: AlanF | last post by:
I have looked over most of the FSW questions in the forum and this one seems like a unique twist. Here it is. In a nutshell, when a .NET service is running on my machine (XP), the fsw file...
7
by: Simon Harvey | last post by:
Hi everyone, I need to make a service that monitors a directory for changes in the files contained within it. I have two questions: 1. I'm going to be using a FileSystemWatcher object to do...
5
by: Azali Adnan | last post by:
I've created a web service project, test it, deployed it to a web server. No Problem. I've created a window app consuming the deployed web service. No Problem. I've created a web application...
1
by: Rob Meade | last post by:
Hi all, I found an article on how to write a Windows service here: http://www.dotnetbips.com/displayarticle.aspx?id=178 It was pretty much what I wanted, I want the service to scan a...
0
by: Bob Davies | last post by:
Hi I have a webservice that retrieves data from a database, this is then returned to the calling client application built in windows forms within a dataset, however upon attempting to create...
3
by: Mike | last post by:
I have created a web service for a client to consume. The element I am having trouble with is, as described in their WSDL: <xsd:element minOccurs="0" ref="LocalData" maxOccurs="1" /> ...
1
by: Ido Flatow | last post by:
Here's the scenario: - Created a web service project - Added 2 services (asmx files) - Created a custom entity ("Customer") - Created a method in each service which returns/receives the above...
4
by: =?Utf-8?B?TmFkYXYgUG9wcGxld2VsbA==?= | last post by:
Hi everybody, I've got two questions about using the EnableSession property with an ASP.NET WebService: First Question: I'm trying to create a web service with EnableSession=true. I can't...
5
by: DotNetDanny | last post by:
Hello Machine: Windows Vista Business, standalone machine (no domain). Installed an old classic ASP webapplication in IIS7, running under a new app.pool with 'NETWORK SERVICE' account (using...
0
by: Jeova Almeida | last post by:
Hello, I created a simple web service for testing purpose in Visual Studio 2005: <%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="WSTest" %> using System;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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,...

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.