How to pass parameter from a front-end GUI to a windows service?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
as a newbie of C#, I am rather surprised when I saw that the method of
System.ServiceProcess.ServiceController - ExecuteCommand(int command) - has
only one parameter. What shall I do if I want to send other data contained in
a front-end GUI, say a windows form, to my windows service (could be on a
remote host)? Following is my code snipper,
-------------------------------------------------------------
In MyGui.cs:
private void buttonFind_Click(object sender, System.EventArgs e)
{
try
{
serviceController1.ExecuteCommand(129);
labelInfo.Text = "Execute command";
}
catch (System.InvalidOperationException exp)
{
MessageBox.Show(exp.ToString());
}
}
--------------------------------------------------------------
In MyService.cs:
protected override void OnCustomCommand(int command)
{
switch (command)
{
case 129:
cmd129Handler();
break;
....

The function cmd129Handler() cannot retrieve parameters from MyGui.
Any ideas or suggestions? Thanks in advance!
 
Hi Josip,
thanks for the concret answer. I visit your site and find that the
IPCServer/IPCClient solution is for two process on the local machine. I will
do some research about Remoting as you suggest. Thanks again!

eedych
 
Back
Top