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

ServiceTimer won't fire

I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something else?
Apr 28 '06 #1
9 1542
Bob
You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something else?

Apr 28 '06 #2
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:
You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something else?


I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.


Apr 28 '06 #3
That is pretty much what I have done as well... but the thing won't start.

"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com...
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:
You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something else?


I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.

Apr 28 '06 #4
On Fri, 28 Apr 2006 11:19:02 -0700, "Thirsty Traveler"
<nf*@nospam.com> wrote:
"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com.. .
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:
You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl. ..
I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something else?


I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.

That is pretty much what I have done as well... but the thing won't start.


I have taken the liberty of "correcting" your top-posting.

Since I am new to DotNet I don't understand what is under the hood.
But I was going to write my service in good old-fashioned Win32 code
and, for that, I know that I need a window (albeit invisible for a
service) and a message pump. My service also includes a SessionSwitch
event processer which never gets signalled.

Could it be that we have to add a MessageQueue or something like it to
the service?
Apr 28 '06 #5
On Fri, 28 Apr 2006 15:58:19 -0400, r norman
<NotMyRealEmail@_comcast.net> wrote:
On Fri, 28 Apr 2006 11:19:02 -0700, "Thirsty Traveler"
<nf*@nospam.com> wrote:
"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com. ..
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:

You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
>I dropped a Timer object onto a Windows Service and set enabled=true...
>however, it does not appear to be firing. Do I need to do something else?
>
I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.

That is pretty much what I have done as well... but the thing won't start.


I have taken the liberty of "correcting" your top-posting.

Since I am new to DotNet I don't understand what is under the hood.
But I was going to write my service in good old-fashioned Win32 code
and, for that, I know that I need a window (albeit invisible for a
service) and a message pump. My service also includes a SessionSwitch
event processer which never gets signalled.

Could it be that we have to add a MessageQueue or something like it to
the service?


OK, MessageQueue is not the right term -- I just saw the words and
assumed it would be a "Windows message pump" but I was wrong. And I
found and changed the property
this->CanHandleSessionChangeEvent = true;
but the service still doesn't respond to session change events.

Apr 28 '06 #6
SR
Try reading this article...

http://www.codeguru.com/csharp/.net/...e.php/c6919__1

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
That is pretty much what I have done as well... but the thing won't start.

"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com...
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:
You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl. ..
I dropped a Timer object onto a Windows Service and set enabled=true...
however, it does not appear to be firing. Do I need to do something
else?


I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.


Apr 28 '06 #7
On Fri, 28 Apr 2006 16:13:19 -0500, "SR" <se********@noreply.com>
wrote:

Is top-posting the standard here? Strange!

Thanks much for that information. It seems to be exactly what I (we)
need. That was going to be my next try -- put the timers in the
equivalent of a worker thread that does have the equivalent of a
message pump! I'll bet my session-change detector will work inside a
worker thread, also.

Try reading this article...

http://www.codeguru.com/csharp/.net/...e.php/c6919__1

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
That is pretty much what I have done as well... but the thing won't start.

"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com...
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:

You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
>I dropped a Timer object onto a Windows Service and set enabled=true...
>however, it does not appear to be firing. Do I need to do something
>else?
>
I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.



Apr 28 '06 #8
There appears to be a bug in the Timer component provided in the toolbox
when dropped onto a service. I deleted this and used the following, which
works.

using System.Threading;

{
public partial class MyService : ServiceBase
{

TimerCallback tcb = null;
Timer timer = null;

protected override void OnStart(string[] args)
{
tcb = new TimerCallback(this.TimerCallback_Tick);
timer = new Timer(tcb, null, 0, 10000);
}

private void TimerCallback_Tick(object state)
{
//Do something
}
}

"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:7n********************************@4ax.com...
On Fri, 28 Apr 2006 11:19:02 -0700, "Thirsty Traveler"
<nf*@nospam.com> wrote:
"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com. ..
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:

You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
>I dropped a Timer object onto a Windows Service and set enabled=true...
>however, it does not appear to be firing. Do I need to do something
>else?
>
I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.

That is pretty much what I have done as well... but the thing won't start.


I have taken the liberty of "correcting" your top-posting.

Since I am new to DotNet I don't understand what is under the hood.
But I was going to write my service in good old-fashioned Win32 code
and, for that, I know that I need a window (albeit invisible for a
service) and a message pump. My service also includes a SessionSwitch
event processer which never gets signalled.

Could it be that we have to add a MessageQueue or something like it to
the service?

Apr 28 '06 #9
On Fri, 28 Apr 2006 16:13:19 -0500, "SR" <se********@noreply.com>
wrote:

Many thanks to both you and to Greg Young for suggesting a system
threading timer. I just avoided the whole thing by putting a
ServiceWorker in the service. It is trivial to put it into a sleep
loop to simulate a timer. Either the worker can implement the timer
tick function or it can signal to the main service through the
progress method. It is very simple and effective.
Try reading this article...

http://www.codeguru.com/csharp/.net/...e.php/c6919__1

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:uj**************@TK2MSFTNGP02.phx.gbl...
That is pretty much what I have done as well... but the thing won't start.

"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:fi********************************@4ax.com...
On Fri, 28 Apr 2006 12:20:38 -0400, "Bob" <ms****@hotmail.com> wrote:

You probably have to set the Interval value too.

"Thirsty Traveler" <nf*@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
>I dropped a Timer object onto a Windows Service and set enabled=true...
>however, it does not appear to be firing. Do I need to do something
>else?
>
I have the same problem.

Working in C++, my InitializeComponent() has

this->ServiceTimer->Enabled = true;
this->ServiceTimer->Interval = 1000;
this->ServiceTimer->Tick += gcnew System::EventHandler(this,
&EMuxServiceWinService::ServiceTimer_Tick);

My OnStart() has

ServiceTimer->Start();

and my OnStop() has

ServiceTimer->Stop();

My OnStart, OnStop, and ServiceTimer_Tick all have code to write to a
log file. The OnStart and OnStart logs get written but the timer tick
log never does.

I confess to being a complete newbie at DotNet code, although I am
rather experienced at MFC and Windows32 programming in general, so I
might be missing something. But what could it be?

Note: I have also tried putting the timer enable and interval set in
OnStart.



Apr 28 '06 #10

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

Similar topics

2
by: Sam Miller | last post by:
Hi, I have a button event that won't fire. I left it on Friday and it worked fine. I came back in on Monday and it won't fire. I tried putting another button and just putting a...
1
by: Ben | last post by:
i'm having trouble getting a custom validator to fire on one of my webforms. i dragged a custom validator onto the form, left all the properties on default, double clicked it, and typed this in the...
5
by: Bob | last post by:
I've got a .NET Framework V1.1 web service running on a Windows 2003 Server that has 2 web methods that are called from a web application on the same server. One is a fire-and-forget method that...
2
by: Ryan Liu | last post by:
Hi, I need the MouseDown event be trigged everytime when you press mouse in a datagrid (System.Windows.Forms). But seems mouse event will only fire once, and it seems changed to edit mode...
3
by: Beavis | last post by:
I hate to repost a message, but I am still at the same point where I was when I originally posted, and hopefully someone else will see this one... Ok, so I have gone off and documented the...
5
by: victorcamp | last post by:
I'm new to Visual Studior C# .Net 2003 on Vista, and have been uable to get my UnhandledExceptionHandler() to fire. I have added these lines to Main() before the Application.Run(): AppDomain...
5
by: T | last post by:
Hi, How do I fire the KeyDown event in Managed VC++? I am getting a compile error saying "event does not have a raise method". Please help. regards, T
3
by: goscottie | last post by:
I have two comboboxes databound at run time. I can make a selection on first one to filter the second one. This works good with applying DataView RowFilter on second combobox. But at that...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.