Update Windows Service member variable from external windows Application in c# [modified]
-
Hello, Can any one tell me how to update the member variable of my windows service from another windows Application. I just need to update a flag variable from external windows application. I want to implement this in c#. The Windows service is already made. Just need to set the flag. This flag is needed to control the launch of another windows application from this running windows service.
modified on Monday, November 16, 2009 3:52 AM
-
Hello, Can any one tell me how to update the member variable of my windows service from another windows Application. I just need to update a flag variable from external windows application. I want to implement this in c#. The Windows service is already made. Just need to set the flag. This flag is needed to control the launch of another windows application from this running windows service.
modified on Monday, November 16, 2009 3:52 AM
-
Hello, Can any one tell me how to update the member variable of my windows service from another windows Application. I just need to update a flag variable from external windows application. I want to implement this in c#. The Windows service is already made. Just need to set the flag. This flag is needed to control the launch of another windows application from this running windows service.
modified on Monday, November 16, 2009 3:52 AM
Probably not what you're looking for but perhaps you could simply use some external resource that both applications may access? If the service uses a FileSystemWatcher it can receive an event when a file changes, and if it only opens the file for reading there should be no problems with the file being in use or anything like that. So the app needing to inform the service of something would simply update a file, or place a new file in a directory, or put the information in a database. Or why not use a message queue? This would also let you queue messages regardless of whether or not the service is up and running of the time of creating the message. I'm sure there are many other possibilities, but generally speaking it seems like an odd way of interfacing between applications to have one application directly modify the state of another - you could hardly get further away from the good OOP practice of encapsulation.
-
There are some ways. You can use self-defined service commands, a small TCP/IP connection, named pipes or maybe names events / shared memory. For the last of these possibilities have a look at this posts. Hope that helps.
Greetings Covean
Thank you for your response. If we develop a windows service in VC++ we can add an "Interface" and can add "Method" to it. This method can be exported to outside applications. This Method can be used by external applications by calling CoCreateInstance() and can get the pointer to the interface and this pointer can call the function. I just like to have similar Implementation but both the Windows Service and Windows Application need to be implemented in c#. Prasad
-
Thank you for your response. If we develop a windows service in VC++ we can add an "Interface" and can add "Method" to it. This method can be exported to outside applications. This Method can be used by external applications by calling CoCreateInstance() and can get the pointer to the interface and this pointer can call the function. I just like to have similar Implementation but both the Windows Service and Windows Application need to be implemented in c#. Prasad
-
The easiest way is to control your service with user-defined service control commands. See ServiceBase.OnCustomCommand and ServiceController.ExecuteCommand.
Greetings Covean
Thankyou Covean, With this approach i implemented and is working. The Link http://www.codeproject.com/KB/dotnet/WindowsServices.aspx is helpful. Thanks, Prasad