Razzie_
asked on
Communicating with a Windows Service
Hi all,
I have a Windows Service that transfers data from one database to another in an x couple of minutes. Now I want to have a user interface with which I can control my service.
For example, I use want to use a progressbar in my UI that displays if the service is done transferring the data or not. I can't just have the UI application call something like 'getTransferProgress()', and have the service return a value to my UI application. Is this possible? And is it possible to set or get properties of a service?
I haven't found _anything_ about this after 2 days of searching. Anyone got a solution? It would be most appreciated!
Razzie
I have a Windows Service that transfers data from one database to another in an x couple of minutes. Now I want to have a user interface with which I can control my service.
For example, I use want to use a progressbar in my UI that displays if the service is done transferring the data or not. I can't just have the UI application call something like 'getTransferProgress()', and have the service return a value to my UI application. Is this possible? And is it possible to set or get properties of a service?
I haven't found _anything_ about this after 2 days of searching. Anyone got a solution? It would be most appreciated!
Razzie
About getTransferProgress or something else - it's up to service writer to expose service control codes which may be used to get/set variuos information.
ASKER
The problem with these links is that they cover just what I already understand, and that is doing things which are defined in the ServiceController class (stopping, pausing, starting, etc).
'About getTransferProgress or something else - it's up to service writer to expose service control codes which may be used to get/set variuos information'
THIS is exactly the thing I have difficulties with. I do not know how to write service control codes to get/set various information. For example if I write this method in my service:
public int getProgress()
{ return somevalue; }
and, in my UI app:
private System.ServiceProcess.Serv iceControl ler sc = new ServiceController("myServi ce");
progressValue = sc.getProgress();
it will return an error since the getProgress() method is not a member of the ServiceController class! So obviously, I would like to know how to get this work. I tried using the ExecuteCommand method, but this method is void and cannot return a value...
'About getTransferProgress or something else - it's up to service writer to expose service control codes which may be used to get/set variuos information'
THIS is exactly the thing I have difficulties with. I do not know how to write service control codes to get/set various information. For example if I write this method in my service:
public int getProgress()
{ return somevalue; }
and, in my UI app:
private System.ServiceProcess.Serv
progressValue = sc.getProgress();
it will return an error since the getProgress() method is not a member of the ServiceController class! So obviously, I would like to know how to get this work. I tried using the ExecuteCommand method, but this method is void and cannot return a value...
You can use .NET Remoting to do the trick....
http://www.codeproject.com/useritems/winservicehost.asp
https://www.experts-exchange.com/questions/20438646/Web-Service-and-Windows-Service-intercommunication.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT15.asp
http://www.codeproject.com/useritems/winservicehost.asp
https://www.experts-exchange.com/questions/20438646/Web-Service-and-Windows-Service-intercommunication.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT15.asp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks testn, that was what I was looking for.
http://www.codeproject.com/csharp/svcmgr.asp