Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my windows form should only run when this service is running and whenever a user enters data using that form that should be inserted into sql database.. is there any way to do this?
Thanks & Regards
Suresh Chinna
Posted
Comments
Prasad Avunoori 12-Jun-14 2:37am    
Can you please brief what does your windows service and windows application do? Why do you want to connect them?
Chinna Suresh 12-Jun-14 3:42am    
yea !
my windows form should take the details from the user and store them in a sql database !
it should do that whenever this service is running

1 solution

Apparently, you will need to use IPC: http://en.wikipedia.org/wiki/Inter-process_communication[^].

It could be sockets (sockets can be used for communications on the same machine; that is what they were originally developed for), named pipes, or, on higher level, "classical" remoting or WPF. Both technologies have "IPC" channels which are based on those named pipes.

As the Window Service is, well… a service and its lifetime is more than that of a UI application, the adequate role of it in this communication with your UI is the server part. You can self-host WPF in the service, have a listening socket using TcpListener and so on. The UI application should connect (or rather try to connect) to the service when it takes a chance for it. For example, you may find it appropriate to register it in the system registry to be run on the user log on. Again, this is only an example; you should do whatever is appropriate according to your goals.

—SA
 
Share this answer
 
v3
Comments
Chinna Suresh 12-Jun-14 5:43am    
yea thank you !
the thing is my windows form send the form details which are given by the user should be inserted into a sql server that in turn should be done by windows service how can i do this..
where should i get started?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900