473,396 Members | 1,706 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.

How to send events to a Window Service

Hi

I have a window service written in C#. I have another application that
requires a lengthy process to be performed like taking backup. How can I
make this lengthy process be performed by window service in such a manner
that my application may invoke the process. Is there any way that I can call
some method written in window service apart from Start, Stop, Pause etc from
my application or firing some custom event to the window service to start
that operation. Its better if I could get some mechanism to call the
service's method as I also need to pass some arguments from my application
to the service that may not be easy to send using event based calls. Please
advice.

Regards

Usman
Oct 28 '05 #1
6 2461
You could use remoting todo this or with .NET2 you can use WCF.

Steve
"Usman" <us***@advcomm.net> wrote in message
news:eb*************@TK2MSFTNGP10.phx.gbl...
Hi

I have a window service written in C#. I have another application that
requires a lengthy process to be performed like taking backup. How can I
make this lengthy process be performed by window service in such a manner
that my application may invoke the process. Is there any way that I can
call
some method written in window service apart from Start, Stop, Pause etc
from
my application or firing some custom event to the window service to start
that operation. Its better if I could get some mechanism to call the
service's method as I also need to pass some arguments from my application
to the service that may not be easy to send using event based calls.
Please
advice.

Regards

Usman

Oct 28 '05 #2
ServiceController.ExecuteCommand lets your app send a one-way integer value
to your Service, which gets it in an OnCustomCommand event. You'll have to
use something like the registry to indicate back to the app that you've
finished.
--
Phil Wilson
[Microsoft MVP-Windows Installer]
Definitive Guide to Windows Installer
http://apress.com/book/bookDisplay.html?bID=280

"Usman" <us***@advcomm.net> wrote in message
news:eb*************@TK2MSFTNGP10.phx.gbl...
Hi

I have a window service written in C#. I have another application that
requires a lengthy process to be performed like taking backup. How can I
make this lengthy process be performed by window service in such a manner
that my application may invoke the process. Is there any way that I can
call
some method written in window service apart from Start, Stop, Pause etc
from
my application or firing some custom event to the window service to start
that operation. Its better if I could get some mechanism to call the
service's method as I also need to pass some arguments from my application
to the service that may not be easy to send using event based calls.
Please
advice.

Regards

Usman

Oct 28 '05 #3

Usman wrote:
Hi

I have a window service written in C#. I have another application that
requires a lengthy process to be performed like taking backup. How can I
make this lengthy process be performed by window service in such a manner
that my application may invoke the process. Is there any way that I can call
some method written in window service apart from Start, Stop, Pause etc from
my application or firing some custom event to the window service to start
that operation. Its better if I could get some mechanism to call the
service's method as I also need to pass some arguments from my application
to the service that may not be easy to send using event based calls. Please
advice.


You can use whatever IPC mechanism you like to send commands from a
user mode app to the service :
- COM
- socket
- Named Pipe
- Event / MMF
- .NET remoting
- etc...

Arnaud
MVP - VC

Oct 28 '05 #4
Hi

You mentioned COM as a possibility. Is there any mechanism through which I
could expose the methods of window service like a com does and call it using
the exact signature of that exposed method from my application including the
parameters. Also how can the .Net Remoting be usefull in this scenario, can
a .Net remoting service expose methods of its own or are you referring to
the Remotable objects.

Regards

Usman Jamil

<ad******@club-internet.fr> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...

Usman wrote:
Hi

I have a window service written in C#. I have another application that
requires a lengthy process to be performed like taking backup. How can I
make this lengthy process be performed by window service in such a manner that my application may invoke the process. Is there any way that I can call some method written in window service apart from Start, Stop, Pause etc from my application or firing some custom event to the window service to start that operation. Its better if I could get some mechanism to call the
service's method as I also need to pass some arguments from my application to the service that may not be easy to send using event based calls. Please advice.


You can use whatever IPC mechanism you like to send commands from a
user mode app to the service :
- COM
- socket
- Named Pipe
- Event / MMF
- .NET remoting
- etc...

Arnaud
MVP - VC

Oct 29 '05 #5

"Usman" <us***@advcomm.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You mentioned COM as a possibility. Is there any mechanism through
which I
could expose the methods of window service like a com does and call it
using
the exact signature of that exposed method from my application
including the
parameters.
You cannot write a COM local server (exe) in .NET. The nearest
equivalent is to write a library assemly with public types and these
types will use some IPC (sockets or .NET remoting) to talk to the
equivalent types implemented in the service. The library assembly can
then be called via COM interop as an inproc server. (using the tlbexp
tool)
Also how can the .Net Remoting be usefull in this scenario, can
a .Net remoting service expose methods of its own or are you referring
to
the Remotable objects.


..NET remoting is an interprocess communication mechanism - it allows two
processes to talk with each other and it requires .NET in both the
client and server. In your case, the service provides the remote
objects. The client accesses these remote objects as if they are local
objects.

Richard
--
http://www.grimes.demon.co.uk/workshops/fusionWS.htm
http://www.grimes.demon.co.uk/workshops/securityWS.htm
Oct 29 '05 #6
Usman wrote:
Hi

You mentioned COM as a possibility. Is there any mechanism through
which I could expose the methods of window service like a com does
and call it using the exact signature of that exposed method from my
application including the parameters. Also how can the .Net Remoting
be usefull in this scenario, can a .Net remoting service expose
methods of its own or are you referring to the Remotable objects.


Both COM and .NET remoting (and Corba too) are mechanisms to expose an
object so that it can be called upon by external programs (even programs on
another machine). The idea is that the service exposes on such object that
can be manipulated by external programs (in your case, the user app). You
can expose whatever functionnality you want through this object. The ser app
will call methods on the object exactly as if it was a local object.

Arnaud
MVP - VC
Nov 5 '05 #7

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

Similar topics

10
by: BadOmen | last post by:
I want my program to send a mouse click to the window at the current mouse position, how do I do that? Example: I have my mouse over a button in Word and then my program is sending the left...
17
by: Michael Fan | last post by:
I am a newbie for web servcie and want to write a web service which monitors the certain field in the database. Once it exceeds the certain value, web service will send out notification to web...
7
by: cider123 | last post by:
I'm coding a project using the following article as reference: http://www.codeproject.com/csharp/DynamicPluginManager.asp In this type of project, plugins are loaded dynamically into a Plugin...
6
by: harvie wang | last post by:
Hi, How to send a message to every window(include child window), I use SendMessage ,but It can't do that. class frmA { public const int WM_test = 0x400 + 1; protected override void...
3
by: M. Simioni | last post by:
Hi, the scenario should be like this: I have a "Server" application, and a UserControl running on an asp.net page. The UserControl sends a SQL Query string via UDP to the Server (after some sort...
1
by: John | last post by:
Hi all, Ive created a new ASP.NET web app and am trying to learn C#/VS 2005. My first hurdle is that I can't find anywhere in the IDE where I can associate a control with it's events. I need to...
6
by: Usman | last post by:
Hi I have a window service written in C#. I have another application that requires a lengthy process to be performed like taking backup. How can I make this lengthy process be performed by...
7
by: Ahmad Jalil Qarshi | last post by:
Hi! I want to develop two applications one a Windows Service and the other a GUI based application. I want some sort of communication between Service and GUI. I have decided to use Remoting for...
2
by: yevron2 | last post by:
Hello, I am trying to get clipboard events using SetClipboardViewer api. It works in a windows form when i override the function: protected override void WndProc(ref...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...

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.