Trigger a function in Form-application from a Service

atmoz

Member
Joined
Jan 21, 2012
Messages
6
Programming Experience
1-3
Hi people,

For a small project I need the possibility to "trigger" a function in a Window-form-application from a Service.
So there are 2 program's. One is the visible Form application with textboxes and buttons and so on...
The other is a sort of service program that runs on the Windows Service account.

Actually the second program is a command-line tool that gets fired by a PHP script from the Apache server.
Because the command-line tool runs in another "environment" then the Windows-form-App, it is NOT possible to communicate (trigger) with both apps.

I know I have to use IPC (InterProcess Communication) and I have download the dozens of sample apps, but I still can't get it to work.

PLEASE can someone give me some sample code, or perhaps sample program(s) to help me out?

I think it's really easy to build what I want, but for me it's a no-go :-(

So for example it has to work like this:

PHP script (running at Apache server) runs a "console/service" app (already working) which "triggers" (via IPC) a already running Windows-Form-app (also already working app) that for example shows a MsgBox with the text in it that is sended by the "console/service" app.


Maybe someone can help me out with this?!

Thanks in advance,

Atmoz
 
Use a TcpListener in the WinForms app to accept a connection from a TcpClient in the service app. A handshake to confirm identity and then the form can do the business. I'm quite sure that there are plenty of examples of using those two classes around.
 
Thanks for the quick reply jmcilhinney!

http://www.vbdotnetforums.com/members/jmcilhinney.htmlI'm going to do some research on that.
It looks like a much better solution then what I'm using now!

At the moment I got what I need (and it works) , BUT not so nice:

The "console" app that being trigged by the PHP script inserts a row in a SQL database, and the Windows-Form-App "polls" the database every 500ms to "see" the new row, and then fires the desired function :)
I can imagine that after a few million polls in a specific time, the database crashes. I also was thinking that this is not all to good for the harddisk where the DB is running at. Is this correct?

Thanks again,

Atmoz
 
Assuming that the mean SQL Server then, if you were going to use a database, you would use the SqlDependency class to push notifications from the database to the app rather than using polling to pull. As long as the number of clients is small, SqlDependency is a good option. That said, using a database for IPC doesn't seem quite right.
 
Back
Top