Services

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tomas Andersson

    Services

    I have two questions regarding services.

    First of.
    Is there any problem with creating VB9 services running timer events om
    Winxp?
    I built a service App and it installs and runs but the timer events doesn´t
    klick.

    Lastly, how do I logon to another computer Win2003 Server and restart /
    check status of a service.


  • Tom Shelton

    #2
    Re: Services

    On 2008-06-27, Tomas Andersson <tomas.andersso n@heatex.comwro te:
    I have two questions regarding services.
    >
    First of.
    Is there any problem with creating VB9 services running timer events om
    Winxp?
    I built a service App and it installs and runs but the timer events doesn´t
    klick.
    What timer? System.Windows. Forms.Timer does NOT work in services. You need
    to be using System.Threadin g.Timer or System.Timers.T imer.
    Lastly, how do I logon to another computer Win2003 Server and restart /
    check status of a service.
    In what context? Programatically ? As a user?

    --
    Tom Shelton

    Comment

    • Tomas Andersson

      #3
      Re: Services

      I tried both System.threadin g.timer and system.timers.t imer and none seemed
      to work



      And I need to restart the service programmaticall y.

      Here is the thing.

      My program creates importfiles for another system. These files can have
      multiple levels that has to be imported from the lowest level to the
      highest. Therefore my program creates these imports and add them to a
      database for temporary storage.

      Another program then looks at the priority and dumps these files to a folder
      where yet another program finds these files and imports them.

      Problem is that this last step uses a little dodgy service that sometime
      loses the connection to the importprogram, or rather the other way round.
      Any who. The solution Is to restart the service so the connection goes up
      again.



      So when the middle program detects that there is imports cued in DB and a
      already bumped importfile has not been touched for some time this should
      restart the service



      /Tomas



      "Tom Shelton" <tom_shelton@co mcastXXXXXXX.ne tskrev i meddelandet
      news:<f6OdnbLFX ZgZkfjVnZ2dnUVZ _rfinZ2d@comcas t.com>...
      On 2008-06-27, Tomas Andersson <tomas.andersso n@heatex.comwro te:
      I have two questions regarding services.
      First of.
      Is there any problem with creating VB9 services running timer events
      om Winxp?
      I built a service App and it installs and runs but the timer events
      doesn´t klick.
      >
      What timer? System.Windows. Forms.Timer does NOT work in services.
      You need to be using System.Threadin g.Timer or System.Timers.T imer.
      >
      Lastly, how do I logon to another computer Win2003 Server and
      restart / check status of a service.
      >
      In what context? Programatically ? As a user?
      >
      --
      Tom Shelton

      Comment

      • Mr. Arnold

        #4
        Re: Services


        "Tomas Andersson" <tomas.andersso n@heatex.comwro te in message
        news:ODpo6pS2IH A.3756@TK2MSFTN GP04.phx.gbl...
        >I tried both System.threadin g.timer and system.timers.t imer and none seemed
        >to work
        >
        You must be doing something wrong.

        >
        >
        And I need to restart the service programmaticall y.
        >
        Here is the thing.
        >
        My program creates importfiles for another system. These files can have
        multiple levels that has to be imported from the lowest level to the
        highest. Therefore my program creates these imports and add them to a
        database for temporary storage.
        >
        Another program then looks at the priority and dumps these files to a
        folder where yet another program finds these files and imports them.
        >
        Problem is that this last step uses a little dodgy service that sometime
        loses the connection to the importprogram, or rather the other way round.
        Any who. The solution Is to restart the service so the connection goes up
        again.
        >
        >
        >
        So when the middle program detects that there is imports cued in DB and a
        already bumped importfile has not been touched for some time this should
        restart the service
        You can use the Service Controller and stop or start a service running on
        another machines. The programs would need to use an Admin account that's
        active on both machines.



        Comment

        • Phill W.

          #5
          Re: Services

          Tomas Andersson wrote:
          Is there any problem with creating VB9 services running timer events om
          Winxp?
          There's no inherent problem - I do it all the time.
          I built a service App and it installs and runs but the timer events doesn´t
          klick.
          One possibility is that your Timer /is/ firing, but that the timer's
          Elapsed() routine cannot be JIT-loaded because there's a referenced Type
          or Assembly missing. The Framework probably throws an exception about
          this, but I've never managed to find anywhere in /my/ code that I can
          /catch/ it!

          Because of this, I only use a Timer /once/ to get me out of the
          "Call-and-Return" structure invoked by the Service Control Manager to
          /start/ the Server; after that, I use Sleep calls within my "main" routine:

          Overrides Sub OnStart()
          TimerX.Start()
          End Sub

          Sub TimerX_Elapsed( ... ) Handles TimerX.Elapsed
          TimerX.Stop()

          Do While Not m_bShutdownRequ ested

          Try
          DoSomethingUsef ul()
          Catch ex as Exception
          ' Log it, or whatever
          ' Don't let the Service Process die
          End Try

          For i as integer = 1 to 15
          System.Threadin g.Thread.Sleep( 1000 )
          Next

          Loop

          End Sub

          HTH,
          Phill W.

          Comment

          Working...