473,566 Members | 3,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Hi all,
as a newbie of C#, I am rather surprised when I saw that the method of
System.ServiceP rocess.ServiceC ontroller - 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_Clic k(object sender, System.EventArg s e)
{
try
{
serviceControll er1.ExecuteComm and(129);
labelInfo.Text = "Execute command";
}
catch (System.Invalid OperationExcept ion 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!
Nov 17 '05 #1
3 10506
Hi,

Basicly what you need is IPC (Interprocess communication) ..
....to accomplish that you could use NamedPipes .. or Remoting .. or TCP/IP
protocol ...

I wroted library on that topic (IPC for .NET):
http://www.habjansoftware.com/ipc_library.aspx
.... it contains IPCServer and IPCClient (and also PipeSender and
PipeReceiver) .. all based on NamedPipes ...

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"eedych" <ee****@discuss ions.microsoft. com> wrote in message
news:BE******** *************** ***********@mic rosoft.com...
Hi all,
as a newbie of C#, I am rather surprised when I saw that the method of
System.ServiceP rocess.ServiceC ontroller - 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_Clic k(object sender, System.EventArg s e)
{
try
{
serviceControll er1.ExecuteComm and(129);
labelInfo.Text = "Execute command";
}
catch (System.Invalid OperationExcept ion 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!

Nov 17 '05 #2
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

"Josip Habjan" wrote:
Hi,

Basicly what you need is IPC (Interprocess communication) ..
....to accomplish that you could use NamedPipes .. or Remoting .. or TCP/IP
protocol ...

I wroted library on that topic (IPC for .NET):
http://www.habjansoftware.com/ipc_library.aspx
.... it contains IPCServer and IPCClient (and also PipeSender and
PipeReceiver) .. all based on NamedPipes ...

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"eedych" <ee****@discuss ions.microsoft. com> wrote in message
news:BE******** *************** ***********@mic rosoft.com...
Hi all,
as a newbie of C#, I am rather surprised when I saw that the method of
System.ServiceP rocess.ServiceC ontroller - 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_Clic k(object sender, System.EventArg s e)
{
try
{
serviceControll er1.ExecuteComm and(129);
labelInfo.Text = "Execute command";
}
catch (System.Invalid OperationExcept ion 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!


Nov 17 '05 #3
Yes, it is for two or more processes only on local machine.

I'm glad i pointed you on right direction ..

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"eedych" <ee****@discuss ions.microsoft. com> wrote in message
news:D4******** *************** ***********@mic rosoft.com...
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

"Josip Habjan" wrote:
Hi,

Basicly what you need is IPC (Interprocess communication) ..
....to accomplish that you could use NamedPipes .. or Remoting .. or
TCP/IP
protocol ...

I wroted library on that topic (IPC for .NET):
http://www.habjansoftware.com/ipc_library.aspx
.... it contains IPCServer and IPCClient (and also PipeSender and
PipeReceiver) .. all based on NamedPipes ...

Regards,
Josip Habjan
URL: http://www.habjansoftware.com

"eedych" <ee****@discuss ions.microsoft. com> wrote in message
news:BE******** *************** ***********@mic rosoft.com...
> Hi all,
> as a newbie of C#, I am rather surprised when I saw that the method of
> System.ServiceP rocess.ServiceC ontroller - 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_Clic k(object sender, System.EventArg s e)
> {
> try
> {
> serviceControll er1.ExecuteComm and(129);
> labelInfo.Text = "Execute command";
> }
> catch (System.Invalid OperationExcept ion 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!


Nov 17 '05 #4

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

Similar topics

2
2432
by: Yarik | last post by:
Hello there! I am working with MS SQL Server 2000. I have a table function that takes an integer parameter and returns a table, and I can successfully use it like this (passing a literal as a parameter): SELECT * FROM MyTableFunction(1)
5
3407
by: wilson | last post by:
Dear all, In this time, I want to pass array to function. What should I declare the parameter in the function?i int array or int array? Which one is correct? /******************************************************** Below is my code: ********************************************************/
1
23498
by: Dion Heskett | last post by:
How can I pass a Class as a parameter to in a method ? i.e. Private myMethod( string pram1, Classobject as pram2) { Classobject.DataSource = reader; Classobject.DataBind(); }
9
12867
by: Jay Douglas | last post by:
Hello, I am needing to pass a class object (this) by reference to a method in a different class. When I do the following code I get the error (Cannot pass '<this>' as a ref or out argument because it is read-only) .. Is there any way to make <this> not read-only? I have simplified the following code. There is a Task class and a Data...
1
7735
by: | last post by:
Hi, I've defined an ObjectDataSource and a parameterized DataSet. I would like it if I could pass the parameter value that describes the query that creates the DataSet as part of a user control declaration. Here's how the parameter is described in the context of my ObjectDataSource: <asp:ObjectDataSource ID="ObjectDataSource1"...
3
5470
by: Brett | last post by:
I have several classes that create arrays of data and have certain properties. Call them A thru D classes, which means there are four. I can call certain methods in each class and get back an array of data. All four classes are the same except for the number of elements in their arrays and the data. I have a MainClass (the form), which...
14
9828
by: Derek Basch | last post by:
This one has always bugged me. Is it better to just slap a "self" in front of any variable that will be used by more than one class method or should I pass around variable between the methods? Flamewar........NOW! jk, I really do want other opinions. Thanks, Derek
4
148221
by: _Mario.lat | last post by:
Hallo, I have a little question: In the function session_set_save_handler I can pass the name of function which deal with session. In Xoops code I see the use of this function like that: session_set_save_handler(array(&$sess_handler, 'open'), array(&$sess_handler, 'close'), array(&$sess_handler, 'read'), array(&$sess_handler, 'write'),...
1
5628
by: khalid sohail | last post by:
hi everybody i want to pass the window size parameter to <asp:hyperlink> attribute Navige URL Property. tell me how to pass the parameter to it.....actually i want to open the new window on the basis to the user click the data in the column i m passing the Query String also to opening page......i have done that work through the datagrid...
24
55095
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new EventHandler(Onbutton_click); I want to pass more information related that event. & want to use that
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7893
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. ...
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5485
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...
0
5213
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...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2085
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
1
1202
muto222
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.