473,785 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting feedback from a Windows Service, to display on a SCM program

Hi all

Does anyone know the best way to get feedback from a Windows Service?
I have written a Windows service which uses a class library (a DLL)
which has a timer which does some operations every <xseconds.
I'd like to be able to somehow get the current 'elapsed' seconds of
the timer, with a view to displaying something on the service control
manager program I have written.
All seems to be OK (service works properly, as does the DLL and the
SCM program) - I just can't seem to find / think of a way to expose
the DLL. All I can get back from the service are the usual
ServiceBase properties.

The DLL is currently a private member of the ServiceBase class - I've
tried adding a public property to expose a property of the DLL, but to
no avail.

Cheers
John

PS - here's the code:

------
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Diagnost ics;
using System.ServiceP rocess;
using System.Text;
using MySMSServLib;

namespace MySMSService
{
/// <summary>
/// SMS service.
/// Entries are written to a table. This service communicates
with
/// a SMS gateway provider's Web Service at intervals and sends
the entries as SMS messages.
/// </summary>
public partial class MySMSService : ServiceBase
{
private MySMSServLib.Ax iomSMSServ srvDLL;

public MySMSService()
{
InitializeCompo nent();
if (!
System.Diagnost ics.EventLog.So urceExists("MyS MSSource"))
{
System.Diagnost ics.EventLog.Cr eateEventSource (
"MySMSSourc e", "MySMSLog") ;
}
eventLogSMS.Sou rce = "MySMSSourc e";
eventLogSMS.Log = "MySMSLog";
}

/// <summary>
/// Start the service and write to log.
/// </summary>
/// <param name="args">
/// Array to pass in parameters with. Currently only SMS
connection type.
/// </param>
protected override void OnStart(string[] args)
{
// use singleton pattern rather than usual 'new'
instantiation.. .
srvDLL = AxiomSMSServ.In stance;
string connType = "1"; // test
if ((args != null) && (args.Length 0))
connType = (string)args.Ge tValue(0);
srvDLL.SMSConne ctionType = int.Parse(connT ype);
string sStarted = "(never Started)";
if (srvDLL.setupOK ())
{
srvDLL.doStart( );
sStarted = System.DateTime .Now.ToString() ;
writeLog("START ED My SMS service: " + sStarted + "\r
\n" + "Connection type: " + connType);
}
else
writeLog("Canno t start service - client settings or
last gateway status problem!");
}

/// <summary>
/// Stop the service and write to log.
/// </summary>
protected override void OnStop()
{
writeLog("STOPP ED My SMS service: " +
System.DateTime .Now);
srvDLL.doStop() ;
}

/// <summary>
/// Pause the service and write to log.
/// </summary>
protected override void OnPause()
{
writeLog("PAUSE D My SMS service: " + System.DateTime .Now);
srvDLL.doPause( );
}

/// <summary>
/// Resume the service and write to log.
/// </summary>
protected override void OnContinue()
{
writeLog("CONTI NUED My SMS service: " +
System.DateTime .Now);
srvDLL.doContin ue();
}

/// <summary>
/// Writes service event log entry.
/// </summary>
/// <param name="txt">
/// The text to write to the event log.
/// </param>
private void writeLog(string txt)
{
eventLogSMS.Wri teEntry(txt);
}
}
}
------

Mar 14 '07 #1
0 1506

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

Similar topics

2
15229
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000 Personal disk from the SQL Server 2000 Enterprise kit as this is reported here on the MSDN web site to be the version that is supported on Windows XP. In fact so many of you kind people confess to having succeeded in doing it. I have tried...
2
7257
by: Zhang Weiwu | last post by:
Hello. Today I found this free service by w3c generate RSS feed from xthml documents: http://www.w3.org/2000/08/w3c-synd/ This message described how this service failed to produce RSS for my site and asks for help:) It seems to me this service could help me generate RSS for my static hompage site. So I did as this page told me, reformed my index page as: > * the title of the channel is taken from the title of the page
2
21913
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be successful. I'm now ready to start my service (I think) but the NET START command does not appear to indicate that the service is available to be run. The output for NET START is below as well. The Services list in the W2K administrator...
4
19013
by: Dao | last post by:
I have created a windows service called MyService. I followed the MSDN sample code to add the following code but it did not work. What I tried was that to start another or external program when MyService starts. I used notepad.exe as an example of a program to be called when MyService starts. I have tried both in the InitializationComponenet() then in the OnStart() Method but none of them work. Any help would be appreciated. private...
4
1753
by: trialproduct2004 | last post by:
Hi all I have removed windows service from add/remove program, still that service is getting displayed in SCM. Problem is at a time of stopping that service error occured and so status of service getting displayed in scm is 'stopping'. and then i tried to uninstall that service from add/remove program. Service is uninstalled cmpletely but still its entrry is there in scm. can someone tell me why this is happening.
3
1357
by: scorpion53061 | last post by:
Hi, I am looking for a code sample that communicates from a client to a remote Windows Service on another computer over the internet, that is the Windows Service performing instructions the client sends. That being said, I also would like feedback on this. Currently in my Windows applications, I do a lot of communication with my servers at work from customers to place orders, check stock status etc. The production server is a AIX...
5
6493
by: marccruz | last post by:
Hi, I am writing a Windows Service in C#. I want to gracefully fail the "protected override void OnStop()" function. To do this, I first tried throwing an Exception in the function. However, that left the Service in a "Stopping" state. I would like to fail the Service in the OnStop function without putting the service in the Stopping state. It would be nice if it's still in the Started state. Is this possible? If so, how?
5
1432
by: Just_a_fan | last post by:
I can get a dump. I can send it in to M$. I can inspect it but cannot get it in my hands so I can not post it here and get comments and/or answers. Can I get hold of that dump somewhere? Is it all in memory or is a file written somewhere on the failing machine's HD? The application does not get to the first line of user code. It is completely repeatable. I have repeated it over and over and sent in the dump several times.
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10346
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.