473,706 Members | 5,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An easy question about windows service

I'm rather new to this with windows service.
I want to get a better understanding because I must use it if I don't want
to use a console application-

I have three important methods below. These are main, constructor for the
service class and a method called OnStart.
I'm from Sweden so I have tried to translate the name on dialog that I use
to start a windows service.
I start the service from
Start->Controllpane l->administratort ool->KomponentServi ce

When you start a service from dialog KomponentServic e the following happens.
You may correct me if I have wrong.
1. Main is always started first.
2. The class is instansiated which means that the constructor is called.
3.The constructor is executing and finally finishes
4.When the constructor has finishes the service control manager(SCM) calls

Is this sequence correct or is it completely wrong.

Here is my main for the service project.
*************** **************
static void Main()
System.ServiceP rocess.ServiceB ase[] ServicesToRun;
// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
// ServicesToRun = new System.ServiceP rocess.ServiceB ase[] {new
Service1(), new MySecondUserSer vice()};
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
MyNewService() };
System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
Here is the Constructor
*************** ***
public MyNewService()
InitializeCompo nent();
if(!System.Diag nostics.EventLo g.SourceExists( "DoDyLogSourse" ))
System.Diagnost ics.EventLog.Cr eateEventSource ("DoDyLogSourse ",

eventLog1.Sourc e = "DoDyLogSourse" ;
// the event log source by which
// the application is registered on the computer

eventLog1.Log = "DoDyLog";

Here I have the OnStart
*************** ***
protected override void OnStart(string[] args)
eventLog1.Write Entry("my service started");
Sep 19 '07 #1
0 1121

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

Similar topics

by: Dan V. | last post by:
Is there a way to query a remote xml file periodically by not using web services? For Windows and Unix platforms. Is there a cheap software product that I can install on each client and my Windows 2000 server and have 'secure' network access? I would love to use VS.NET to access both windows and Unix/Linux xml files.
by: David Sugar | last post by:
Please forgive the stoopid question... I have just started with C++ .NET 2003, I am working through one of the Microsoft books (C++.NET Step by Step) In chapter 2 it is asking me to create a Managed C++ Application. However this option is not one of my possible templates in the add project dialog. Is there something missing? - or - are these called something else in version 2003? The posible templates in
by: Julian McMaster | last post by:
Here's what I need to do. I have to consume a web service using a Windows client application. I want to write the application using VB.NET. I have some experience with earlier versions of VB, and I have the new software loaded. I'm just not sure how to get started. I've searched the Internet and there appears to be dozens of ways to accomplish this, but none of the examples are complete. The web service is at an external site and was...
by: 1944USA | last post by:
Is there any way to run 2 or more instances of the same Windows Service on a server? I've started creating 2 different Windows services that do exactly the same thing and it just seams like a waste when all I am trying to do is change the name of the service so that I can install it a second time. Thanks
by: Water Cooler v2 | last post by:
I want to run a service at the background but also provide some user interface for editing some configuration options. In this regard, my questions are: 1. Can a Windows Service have a UI along with it? 2. Can I associate a NotifyIcon (systray icon) with a Web service? 3. Can a Windows service be such that it runs only on a particular Windows account on the domain? I mean can it use Windows Authentication to see if it must start up on a...
by: Kürþat | last post by:
Hi all, I want to host a remote object in a windows service. This remote object fires events about service state. Clients connect and consume this events. The service configures and marshal remote object in its constructor. When a client application starts it connects remote object, registers events and monitors service state. So far so good. When service stops, it fires stop event via remote object and all clients know the service was...
by: Jaye | last post by:
I have facing a difficult problem about windows service I have created a windows Service and I have add some set/get method to return the value that caluate in background. And i have another window form application, in this, i would like to get back the value in the method that added in my windows service. Is it possible, if yes, how can i get it?
by: =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post by:
Now I have a web application, a web service and a SQL Server database. The Web application will invoke the web service, the web service invokes the SQL Server stored procedure. I let the web service run in an application pool which runs under a domain user, this domain user has permissions of accessing database and the connection to database is trusted connection. All these work well. The web application will be used in internet (not...
by: TC | last post by:
I have a VB.Net application which uses System.Data.OleDb to connect to a Jet database. Recently, I learned that MDAC no longer contains Jet drivers. I'm confused what that means for my application. Can someone help me with answers to these basic questions? First of all, does the absence of Jet driver from MDAC imply that most computers in the future will lack Jet drivers? Second, if I use a Visual Studio setup project to package my...
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...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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...
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();...
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...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.