Please excuse the cross-posting. This question was raised in
microsoft.public.dotnet.general but hasn't been answered so I am
trying where I can.
There are two of us who have the same problem in a service: the
Timer::Tick event processor never gets called. We have set the timer
interval, enabled it, and started it, but still nothing.
In my case, I also have enabled an event handler to detect
SessionSwitch, but that never gets called either. Yes, I enabled the
CanHandleSessionChangeEvent property. My event processors write to a
log file, as do OnStart and OnStop service events but only the latter
log entries ever appear. My timer code works perfectly well in a form
program, but not my service.
I am new to dotNet programming so I don't understand what is behind
the scenes. No doubt I (we) are neglecting something simple. For
example, I know that in ordinary Win32 programming, responding to a
timer or to session events requires a window (albeit invisible in a
service) with a message pump, something that a service would not
ordinarily have. Is that the problem?
How do you use a timer in a service? 2 2443
I have heard of lots of flakey timer behaviors in services.
In nearly all cases uses System.Threading.Timer http://www.dotgnu.org/pnetlib-doc/Sy...ing/Timer.html fixed the
issues.
Cheers,
Greg
"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:5g********************************@4ax.com... Please excuse the cross-posting. This question was raised in microsoft.public.dotnet.general but hasn't been answered so I am trying where I can.
There are two of us who have the same problem in a service: the Timer::Tick event processor never gets called. We have set the timer interval, enabled it, and started it, but still nothing.
In my case, I also have enabled an event handler to detect SessionSwitch, but that never gets called either. Yes, I enabled the CanHandleSessionChangeEvent property. My event processors write to a log file, as do OnStart and OnStop service events but only the latter log entries ever appear. My timer code works perfectly well in a form program, but not my service.
I am new to dotNet programming so I don't understand what is behind the scenes. No doubt I (we) are neglecting something simple. For example, I know that in ordinary Win32 programming, responding to a timer or to session events requires a window (albeit invisible in a service) with a message pump, something that a service would not ordinarily have. Is that the problem?
How do you use a timer in a service?
"Greg Young [MVP]" <Dr*************@hotmail.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl... I have heard of lots of flakey timer behaviors in services.
System.Windows.Forms.Timer won't work in any context which lacks a message
loop since it's based on WM_TIMER message handling. Most services lack a
message loop. In nearly all cases uses System.Threading.Timer http://www.dotgnu.org/pnetlib-doc/Sy...ing/Timer.html fixed the issues.
That would be appropriate for most uses in a service. Of course, you have
to be careful using System.Threading.Timer because the timer events will be
raised in a different thread from the one that started the timer. This may
cause problems even outside the Windows Forms/GUI environment if you haven't
made things thread-safe.
-cd This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ray |
last post by:
Hi,
I just wrote a windows service application to call a function of another
object periodically. I used System.Server.Timer and I found that it works
fine within the first 2 hours but the...
|
by: Chris |
last post by:
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 =...
|
by: andrewcw |
last post by:
I am trying to do a windows service with C#. I am using as
a base the VB.NET article in VS, but I thing the
WITHEVENTS timer notation is a delegate. Can anyone
provide sample code & anh hints. ...
|
by: DaveF |
last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2
minutes and then download the files. Then repeat every 2 minutes. The files
just seem to stop downloading. Does that timer...
|
by: Dhilip Kumar |
last post by:
Hi all,
I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue...
|
by: Scott H |
last post by:
Hello,
I'm having a go at writing my first Windows Service in VB.NET and I'm
having a problem. I have it installed ok and started the service
sucessfully, I can stop it, and restart it fine, the...
|
by: John David Thornton |
last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and
I've coded it as shown below. However, when I install the service and then
start it in MMC, I get a peculiar message:
...
|
by: adasilva |
last post by:
I have create a Windows service that uses a timer to access a Web Service.
The service is set to start Automatically and its using the local system
account. The service also logs events to the...
|
by: Kevin Antel |
last post by:
We have written a service that uses a timer control to check for a process
every 60 seconds. This is installed on a Windows 2003 Server w/SP1.
The problem we are running into is that the service...
|
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...
|
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...
|
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: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |