473,320 Members | 2,027 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,320 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 1231
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.