Results 1 to 6 of 6

Thread: How would you do it?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167

    How would you do it?

    I have a Windows Service and need a Windows Forms based User Interface so I can control, configure and monitor the service.

    Now it's pretty straight forward to be able to start, stop, pause the service but does anyone have any recommendations as to how I will communicate between the service and the user interface?

    Typical actions will be:

    • Pass XML dataset from the Service to the UI when requested
    • Update Service variables (e.g. Options) from the UI
    • Execute/Call Service functions from the UI


    So has anyone worked with this kind of architecture before? I have a few ideas but would like to hear some recommendations or opinions.

    Thanks!

    Justy.


  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I'd say your best bet is remoting. Have the service remote some kind of controller class that an exe can link into and use.

  3. #3
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551
    well, I'm going to suggest an alternative to Edneeis's method (which is probably a lot more proper than mine, but i gotta do it just to bug Edneeis and resist Remoting )..

    anyways... You may see under the evnets you can handle in your windows service one called "OnCustomCommand(command As Integer)" ... from the ServiceControllerClass, you can call the OnCustomCommand and send any integer you want to the windows service this way..


    as you can imagine, this is a bit limiting since it only allows you to pass integers.... But you could easily do something like put a string at a specific location in the registry and then call the OnCustomCommand and then retrieve that registry value in the windows service...

    This method of course is a bit hack, but would work nicely if you need very simple communication...

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Ahh Redth, i'd have been disappointed if you hadn't shot down the idea of using remoting

    Whats a good idea for a service? Just to use in an example, something fairly simple.

  5. #5
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    Originally posted by Redth
    well, I'm going to suggest an alternative to Edneeis's method (which is probably a lot more proper than mine, but i gotta do it just to bug Edneeis and resist Remoting )..

    anyways... You may see under the evnets you can handle in your windows service one called "OnCustomCommand(command As Integer)" ... from the ServiceControllerClass, you can call the OnCustomCommand and send any integer you want to the windows service this way..


    as you can imagine, this is a bit limiting since it only allows you to pass integers.... But you could easily do something like put a string at a specific location in the registry and then call the OnCustomCommand and then retrieve that registry value in the windows service...

    This method of course is a bit hack, but would work nicely if you need very simple communication...
    To expand on this idea, if your service has a fixed set of parameters then you could just pass in a bit-wise value and determine the number of parameters to enable/disable, based on that value.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167
    Thanks fellas.. was already aware of Redth's method of communicating but it's a bit too limiting in this situation. Remoting sounds interesting though so I'm off to do some reading!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width