473,769 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help on Windows Service ?

Dear all,

I have a process named P1 ( windows form or console app) which need to send
a command to a windows service and then my servcie will proceed that command
and do proper opertaion.

For instance P1 could send DATAREADY, my service shoulld receive that
command and handle it.

What is the way for my service to register to that command ?
Does P1 can geenrate an event that my servcie will register ? how ?

Thnaks for help
regards
serge
May 1 '07 #1
3 1291

"calderara" <ca*******@disc ussions.microso ft.comwrote in message
news:93******** *************** ***********@mic rosoft.com...
Dear all,

I have a process named P1 ( windows form or console app) which need to
send
a command to a windows service and then my servcie will proceed that
command
and do proper opertaion.

For instance P1 could send DATAREADY, my service shoulld receive that
command and handle it.

What is the way for my service to register to that command ?
Does P1 can geenrate an event that my servcie will register ? how ?

You simply do this.

1) In your windows form or console application, you instantiate a Service
Controller that communicates with the Service.

ServiceControll er sc = new ServiceControll er("the service");
sc.Execute(201) ;

Just like there is a Onstop, Onstart, etc, etc event in a Service
application, there is a OnCustomCommand event.
2) In the Service application, you setup a OnCustomCommand event.

protected override void OnCustomCommand (int command)
{
if (command == 201)
Help();
else if (command == 200)
Help1();
}

I guess you can pass a string to the event, but I have only used an integer.

You can look it up use Google.

May 1 '07 #2
Thnaks arnold.
I have seen that already but coulsd find the link where I found it once..

regards
serge

"Mr. Arnold" wrote:
>
"calderara" <ca*******@disc ussions.microso ft.comwrote in message
news:93******** *************** ***********@mic rosoft.com...
Dear all,

I have a process named P1 ( windows form or console app) which need to
send
a command to a windows service and then my servcie will proceed that
command
and do proper opertaion.

For instance P1 could send DATAREADY, my service shoulld receive that
command and handle it.

What is the way for my service to register to that command ?
Does P1 can geenrate an event that my servcie will register ? how ?


You simply do this.

1) In your windows form or console application, you instantiate a Service
Controller that communicates with the Service.

ServiceControll er sc = new ServiceControll er("the service");
sc.Execute(201) ;

Just like there is a Onstop, Onstart, etc, etc event in a Service
application, there is a OnCustomCommand event.
2) In the Service application, you setup a OnCustomCommand event.

protected override void OnCustomCommand (int command)
{
if (command == 201)
Help();
else if (command == 200)
Help1();
}

I guess you can pass a string to the event, but I have only used an integer.

You can look it up use Google.
May 1 '07 #3

"calderara" <ca*******@disc ussions.microso ft.comwrote in message
news:21******** *************** ***********@mic rosoft.com...
Thnaks arnold.
I have seen that already but coulsd find the link where I found it once..
??????????

May 1 '07 #4

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

Similar topics

0
3685
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob , /webapps/sue) and i have added the folders bob, sue in my server.xml(in the context path). When i am trying to run jsp files from my browser, it works fine. But, the following jsp files reports some exceptions which is quite hard to understand. Here is...
7
3925
by: Simon Harvey | last post by:
Hi everyone, I need to make a service that monitors a directory for changes in the files contained within it. I have two questions: 1. I'm going to be using a FileSystemWatcher object to do the monitoring - but do I need to somehow involve another thread to allow the service to do other stuff as well, or is another thread created automatically when the FileSystemMonitor object is created?
5
297
by: Girish | last post by:
Im looking for information on how to build a windows service (not web service) on a .net enabled platform. Now, ive had some experience building services using vc++ 6.0 - and I can tell you its not straightforward. Now, I tried to examine the code that was auto generated when you create a new windows service project in vs.net 2003 (C#). I could not see any code for 1) Installing, uninstalling services. How can this be done in the .net...
1
2428
by: Hank | last post by:
I am writing a windows service in C#.NET which will manage image capturing devices, when client connects to the service, at some point the service need to expose a device dialog to the client for setting some device specific parameters. According to MSDN docs, classes within the Windows Forms namespace are not supported for use within a Windows service. So How can I do that? Thanks! HELP: expose Windows dialog from Windows Service
13
3630
by: Siegfried Heintze | last post by:
I refered the engineer at my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 where he tried to follow the directions there. He said there was no such file: Document settings\ServerName\ASPNET\Local settings\Temp I said it must be a typo, they meant to say c:\Documents And Settings\Server Name\ASPNET\Local settings\temp.
5
1538
by: Matthew Speed | last post by:
(About me: I know very little about writing server applications. I have done plenty of VB6 desktop app work but this is my first server program. I got it to work by modifying examples. I understand what it is doing but not much about what is involved in extending it. ) I am not necessarily looking for code examples here, just some pointers as to what direction I need to proceed to resolve these things. I have written a...
5
2871
by: Andrew | last post by:
Hey all, Requesting help from the VB.Net gurus in here. I was given a task to write a Windows Service (VB.Net) that would run an external program, and if that program closed for any reason (other than the service being stopped) it would restart it. I have written the service to do just this, and for testing purposes I am running the program Notepad. And I even have it making entries in the System Event Log. However, and this is my...
3
2607
by: zxo102 | last post by:
Hi there, I have a python application (many python scripts) and I start the application like this python myServer.py start in window. It is running in dos window. Now I would like to put it in background as NT service. I got a example code: SmallestService.py from chapter 18 of the book "Python Programming On Win32" by Mark Hammond etc. The code is as follows and runs well as an NT service.
0
1486
by: JM | last post by:
I am working on an application which uses xml file as a database. The application has 2 interfaces which accesses this xml file. "Windows application written in C#" and "Windows Service written in C#". Both have been developed in .NET Framework 2.0. Recently I have started getting error in Windows application that "xml file is being locked by some other process". I have debugged and find out that its my Windows Service which is locking...
5
3307
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name? Why do I need to set a property within my code to the service name? Are all these required or am I just doing this for consistency purposes?
0
9579
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
10199
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
9981
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
9850
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 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...
0
8862
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
7396
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
5436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
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
3
2810
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.