Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Advice Windows Service with Status Form

Advice Windows Service with Status Form

Scheduled Pinned Locked Moved Visual Basic
csharphelpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ESTAN
    wrote on last edited by
    #1

    Hello guys, I like your advice. I am programming a windows service in vb.net 2003 and I'd like to have the windows service run a windows form that provide me status information concerning the tasks of the service. And to make it more nice, minimize the form to the system tray. How I do this properly? I have done the following: Private test As Thread Public Shared fStatus As New FormStatus ' The windows form Protected Overrides Sub OnStart(ByVal args() As String) ' Create the windows form thread test = New Thread(New ThreadStart(AddressOf Me.dotest)) test.Start() ' The real Service work Communication.StartCommunication() End Sub Private Sub dotest() fStatus.Show() End Sub With this code, the form disappears almost immediately. If I use ShowDialog() instead of Show(), the notify icon does not process the click events. Can anyone give me a nice advice to solve this issue? Thanks.

    T 1 Reply Last reply
    0
    • E ESTAN

      Hello guys, I like your advice. I am programming a windows service in vb.net 2003 and I'd like to have the windows service run a windows form that provide me status information concerning the tasks of the service. And to make it more nice, minimize the form to the system tray. How I do this properly? I have done the following: Private test As Thread Public Shared fStatus As New FormStatus ' The windows form Protected Overrides Sub OnStart(ByVal args() As String) ' Create the windows form thread test = New Thread(New ThreadStart(AddressOf Me.dotest)) test.Start() ' The real Service work Communication.StartCommunication() End Sub Private Sub dotest() fStatus.Show() End Sub With this code, the form disappears almost immediately. If I use ShowDialog() instead of Show(), the notify icon does not process the click events. Can anyone give me a nice advice to solve this issue? Thanks.

      T Offline
      T Offline
      Tom Deketelaere
      wrote on last edited by
      #2

      I'v never done this before but from the top of my had I see at least one problem (obstical): a service can run without a user being logged in and if this is the case I doubt that you'r form will show, I think it probably will generate a error or at least some strange behavior. So you'll have to check wheter or not there is a user logged in. as to why the form disappears I don't really know but I would try putting the 'real service work' also in a sepparte thread. I don't know if it will solve the problem but it's worth a try I think. I think that if you always want a form to be displayed and the communcation.startcommunication only has to work if a user is logged in it probably be best that you write it in a windows form application and put that application in the startup of the user. I'v only experimented with services a few times but I can tell you that if you try to do to much in them they start acting strange

      If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

      E 1 Reply Last reply
      0
      • T Tom Deketelaere

        I'v never done this before but from the top of my had I see at least one problem (obstical): a service can run without a user being logged in and if this is the case I doubt that you'r form will show, I think it probably will generate a error or at least some strange behavior. So you'll have to check wheter or not there is a user logged in. as to why the form disappears I don't really know but I would try putting the 'real service work' also in a sepparte thread. I don't know if it will solve the problem but it's worth a try I think. I think that if you always want a form to be displayed and the communcation.startcommunication only has to work if a user is logged in it probably be best that you write it in a windows form application and put that application in the startup of the user. I'v only experimented with services a few times but I can tell you that if you try to do to much in them they start acting strange

        If my help was helpfull let me know, if not let me know why. The only way we learn is by making mistaks.

        E Offline
        E Offline
        ESTAN
        wrote on last edited by
        #3

        You have completely the reason. Is there a way to separate the two from each other, the service is running in the background, and when you log on, you start the application, that uses functions/methods of the service? Does anyone has experience with this?

        D 1 Reply Last reply
        0
        • E ESTAN

          You have completely the reason. Is there a way to separate the two from each other, the service is running in the background, and when you log on, you start the application, that uses functions/methods of the service? Does anyone has experience with this?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You normally would use two different projects. You write a Windows Service that does it's job, but also starts a server, be it a socket server that talks like an email server does, or a .NET Remoting server, or something using WCF. There's a bunch of different ways of doing it. The second app would be run by the user and would connect to the services server to issue commands and get status information.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You normally would use two different projects. You write a Windows Service that does it's job, but also starts a server, be it a socket server that talks like an email server does, or a .NET Remoting server, or something using WCF. There's a bunch of different ways of doing it. The second app would be run by the user and would connect to the services server to issue commands and get status information.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            E Offline
            E Offline
            ESTAN
            wrote on last edited by
            #5

            Well, thanks for the advice. In the meanwhile I implemented a NET remoting system among the 2 different projects. And it works great. Sending a message to the server, it does some action and than respond to the status application.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups