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

Service problems

I can't seem to get this windows service to work properly, I get a
message about some services stopping automatically if they have no work
to do, I suspect it may be with the way I start the timer in the
OnStart method, any help is greatly appreciated.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
using System.Timers;

namespace XpedX10
{
public partial class Service1 : ServiceBase
{
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int
hModule, int dwFlags);
X10Unified.Senders.Firecracker f;
Service.gLink serv = new Service.gLink();
String some;
Timer time = new Timer();
int orders = 0;
int oldorders = 0;

public Service1()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
time.Interval = 30000;
time.Elapsed += new ElapsedEventHandler(time_Elapsed);
time.Enabled = true;
time.Start();
f =
X10Unified.Senders.Firecracker.GetInstance(Int32.P arse(System.Configuration.ConfigurationSettings.Ap pSettings["COM_Port"]));
}

void time_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
orders = serv.newXpedx();
if (orders 0 && oldorders == 0)
{
f.SendCommand('G', 1,
X10Unified.Senders.Firecracker.Commands.TurnOn);
PlaySound("c:\\windows\\media\\tada.wav", 0, 1);
}
if (orders == 0 && oldorders != 0)
{
f.SendCommand('G', 1,
X10Unified.Senders.Firecracker.Commands.TurnOff);
}
oldorders = orders;
}
catch (Exception ex)
{
}
}

protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary
to stop your service.
}
}
}

Jul 24 '06 #1
3 1164
I'm guessing it has something to do with that timer, but i'm not sure
what...

Jul 24 '06 #2
So, I moved some of the timer code out of the OnStart, thinking that it
might not work if it was thinking it was going forever, but it still
doesn't work...it now looks like this

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Runtime.InteropServices;
using System.Timers;

namespace XpedX10
{
public partial class Service1 : ServiceBase
{
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int
hModule, int dwFlags);
X10Unified.Senders.Firecracker f;
Service.gLink serv = new Service.gLink();
Timer time = new Timer();
int orders = 0;
int oldorders = 0;

public Service1()
{
InitializeComponent();
time.Interval = 30000;
time.Elapsed += new ElapsedEventHandler(time_Elapsed);
f =
X10Unified.Senders.Firecracker.GetInstance(Int32.P arse(System.Configuration.ConfigurationSettings.Ap pSettings["COM_Port"]));
}

protected override void OnStart(string[] args)
{
time.Enabled = true;
}

void time_Elapsed(object sender, ElapsedEventArgs e)
{
try
{
orders = serv.newXpedx();
if (orders 0 && oldorders == 0)
{
f.SendCommand('G', 1,
X10Unified.Senders.Firecracker.Commands.TurnOn);
PlaySound("c:\\windows\\media\\tada.wav", 0, 1);
}
if (orders == 0 && oldorders != 0)
{
f.SendCommand('G', 1,
X10Unified.Senders.Firecracker.Commands.TurnOff);
}
oldorders = orders;
}
catch (Exception ex)
{
}
}

protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary
to stop your service.
}
}
}

co**@garcia-co.com wrote:
I'm guessing it has something to do with that timer, but i'm not sure
what...
Jul 24 '06 #3
got it working...i was just having a brain fart...referencing the wrong
directory

Jul 24 '06 #4

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

Similar topics

2
by: cd | last post by:
Is there a specific process or permissions that must be granted to get a .NET (framework 1.4) Window Service to run properly on a Windows 2003 Server? I built a Windows Service to start two local...
9
by: David W. Fenton | last post by:
See: Updated version of the Microsoft Jet 4.0 Service Pack 8 replication files is available in the Download Center http://support.microsoft.com/?scid=kb;en-us;321076 This includes the Jet 4...
0
by: Ross Bennett | last post by:
Ahoy, Folks! I've been looking all over for this, but I just can't seem to shake any documentation out of the MSDN or from Google. I've reviewed every .NET article on developing Windows...
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
7
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully...
1
by: Lee Greco | last post by:
I'm looking for some advice on how to proceed. Here's the scenario: I've got to develop a high availability VB.Net web service that basically acts as a middle man between the web service...
4
by: Don Curtis | last post by:
If I use GDI+ within a service, what problems can I expect? Why can't GDI+ be used within a service? http://msdn2.microsoft.com/en-us/library/system.drawing.aspx "Classes within the...
3
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
3
by: Russ | last post by:
I have a Web Service that was originally created with .NET VC 2003, and subsequently converted to the 2005 version. It works fine when built as a debug version, and run on the workstation it was...
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: 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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.