473,396 Members | 2,109 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,396 software developers and data experts.

An easy question about windows service

Hello
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->Controllpanel->administratortool->KomponentService

When you start a service from dialog KomponentService 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
OnStart

Is this sequence correct or is it completely wrong.

Here is my main for the service project.
*****************************
static void Main()
{
System.ServiceProcess.ServiceBase[] 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.ServiceProcess.ServiceBase[] {new
Service1(), new MySecondUserService()};
//
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
MyNewService() };
System.ServiceProcess.ServiceBase.Run(ServicesToRu n);
}
Here is the Constructor
******************
public MyNewService()
{
InitializeComponent();
if(!System.Diagnostics.EventLog.SourceExists("DoDy LogSourse"))
System.Diagnostics.EventLog.CreateEventSource("DoD yLogSourse",
"DoDyLog");

eventLog1.Source = "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.WriteEntry("my service started");
}
//Tony
Sep 19 '07 #1
0 1109

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

Similar topics

6
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...
1
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...
6
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,...
1
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...
4
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...
0
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...
2
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...
3
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...
5
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....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
tracyyun
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...

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.