keep program running

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • William LaMartin

    keep program running

    If I have a Windows application with no form--only a module that starts with
    sub main and which has a system timer, in the elapsed event of which I want
    to run some code, how can I keep this program from running through the sub
    main code and then closing without ever firing the timer?

    I can put

    Do While 3 <> 2

    Loop

    at the end of the sub main code and that seems to work, but there must be a
    better way.


  • Vijay

    #2
    Re: keep program running

    Are you trying to run some process, that will execute a serious of steps?

    VJ

    "William LaMartin" <lamartin@tampa bay.rr.com> wrote in message
    news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=blue]
    > If I have a Windows application with no form--only a module that starts
    > with sub main and which has a system timer, in the elapsed event of which
    > I want to run some code, how can I keep this program from running through
    > the sub main code and then closing without ever firing the timer?
    >
    > I can put
    >
    > Do While 3 <> 2
    >
    > Loop
    >
    > at the end of the sub main code and that seems to work, but there must be
    > a better way.
    >[/color]


    Comment

    • Cor Ligthert [MVP]

      #3
      Re: keep program running

      William,

      As you tell it there is not any code needed. Can you rephrase.

      Probably it is a loop with a threading.threa d.sleep in it.

      However there your text does not tell how your program stops.

      Cor

      "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
      news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=blue]
      > If I have a Windows application with no form--only a module that starts
      > with sub main and which has a system timer, in the elapsed event of which
      > I want to run some code, how can I keep this program from running through
      > the sub main code and then closing without ever firing the timer?
      >
      > I can put
      >
      > Do While 3 <> 2
      >
      > Loop
      >
      > at the end of the sub main code and that seems to work, but there must be
      > a better way.
      >[/color]


      Comment

      • Simmo

        #4
        Re: keep program running

        Like a windows service?

        "...enable you to create long-running executable applications that run in
        its own Windows session, which then has the ability to start automatically
        when the computer boots and also can be manually paused, stopped or even
        restarted"




        Troy



        "William LaMartin" <lamartin@tampa bay.rr.com> wrote in message
        news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=blue]
        > If I have a Windows application with no form--only a module that starts
        > with sub main and which has a system timer, in the elapsed event of which
        > I want to run some code, how can I keep this program from running through
        > the sub main code and then closing without ever firing the timer?
        >
        > I can put
        >
        > Do While 3 <> 2
        >
        > Loop
        >
        > at the end of the sub main code and that seems to work, but there must be
        > a better way.
        >[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: keep program running

          "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=blue]
          > If I have a Windows application with no form--only a module that starts
          > with sub main and which has a system timer, in the elapsed event of which
          > I want to run some code, how can I keep this program from running through
          > the sub main code and then closing without ever firing the timer?[/color]

          'Application.Ru n()'.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • William LaMartin

            #6
            Re: keep program running

            A process that fires at regular intervals based on a timer. I tried to use
            a Windows service to do this but found that it ran in a different account
            than did the user so it had no knowledge of things like key strokes, etc
            that the user was making.

            "Vijay" <vijay@msdiscus sions.com> wrote in message
            news:OaSPQLtVGH A.900@TK2MSFTNG P15.phx.gbl...[color=blue]
            > Are you trying to run some process, that will execute a serious of steps?
            >
            > VJ
            >
            > "William LaMartin" <lamartin@tampa bay.rr.com> wrote in message
            > news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=green]
            >> If I have a Windows application with no form--only a module that starts
            >> with sub main and which has a system timer, in the elapsed event of
            >> which I want to run some code, how can I keep this program from running
            >> through the sub main code and then closing without ever firing the timer?
            >>
            >> I can put
            >>
            >> Do While 3 <> 2
            >>
            >> Loop
            >>
            >> at the end of the sub main code and that seems to work, but there must be
            >> a better way.
            >>[/color]
            >
            >[/color]


            Comment

            • William LaMartin

              #7
              Re: keep program running

              I do not understand your answer.

              "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
              news:OXbvkswVGH A.1536@TK2MSFTN GP15.phx.gbl...[color=blue]
              > "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=green]
              >> If I have a Windows application with no form--only a module that starts
              >> with sub main and which has a system timer, in the elapsed event of
              >> which I want to run some code, how can I keep this program from running
              >> through the sub main code and then closing without ever firing the timer?[/color]
              >
              > 'Application.Ru n()'.
              >
              > --
              > M S Herfried K. Wagner
              > M V P <URL:http://dotnet.mvps.org/>
              > V B <URL:http://classicvb.org/petition/>[/color]


              Comment

              • William LaMartin

                #8
                Re: keep program running

                I am trying to run process that fires at regular intervals based on a timer.
                I tried to use a Windows service to do this but found that it ran in a
                different account than did the user so it had no knowledge of things like
                key strokes, etc that the user was making.

                Here is the sub main code. All of the work is actually done in the timer
                code.

                Public Sub Main()

                MyTimer1.Interv al = 50
                MyTimer1.Enable d = True
                MyTimer2.Interv al = 10000
                MyTimer2.Enable d = True
                'MsgBox("starte d") 'this will keep the program running if not
                clicked on
                'here is another method of keeping the program running to allow the
                timers to fire.
                Do While 3 <> 2

                Loop

                End Sub


                "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
                news:eSHhK3tVGH A.5012@TK2MSFTN GP10.phx.gbl...[color=blue]
                > William,
                >
                > As you tell it there is not any code needed. Can you rephrase.
                >
                > Probably it is a loop with a threading.threa d.sleep in it.
                >
                > However there your text does not tell how your program stops.
                >
                > Cor
                >
                > "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
                > news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=green]
                >> If I have a Windows application with no form--only a module that starts
                >> with sub main and which has a system timer, in the elapsed event of
                >> which I want to run some code, how can I keep this program from running
                >> through the sub main code and then closing without ever firing the timer?
                >>
                >> I can put
                >>
                >> Do While 3 <> 2
                >>
                >> Loop
                >>
                >> at the end of the sub main code and that seems to work, but there must be
                >> a better way.
                >>[/color]
                >
                >[/color]


                Comment

                • William LaMartin

                  #9
                  Re: keep program running

                  I can not use a Windows Service for this application. I tried. The service
                  runs in an account that knows nothing about certain things the user is doing
                  like keystrokes.

                  "Simmo" <troy@NO-SPAMebswift.com > wrote in message
                  news:egQ3iDuVGH A.4952@TK2MSFTN GP09.phx.gbl...[color=blue]
                  > Like a windows service?
                  >
                  > "...enable you to create long-running executable applications that run in
                  > its own Windows session, which then has the ability to start automatically
                  > when the computer boots and also can be manually paused, stopped or even
                  > restarted"
                  >
                  > http://www.codeproject.com/dotnet/si...owsservice.asp
                  >
                  >
                  > Troy
                  >
                  >
                  >
                  > "William LaMartin" <lamartin@tampa bay.rr.com> wrote in message
                  > news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=green]
                  >> If I have a Windows application with no form--only a module that starts
                  >> with sub main and which has a system timer, in the elapsed event of
                  >> which I want to run some code, how can I keep this program from running
                  >> through the sub main code and then closing without ever firing the timer?
                  >>
                  >> I can put
                  >>
                  >> Do While 3 <> 2
                  >>
                  >> Loop
                  >>
                  >> at the end of the sub main code and that seems to work, but there must be
                  >> a better way.
                  >>[/color]
                  >
                  >[/color]


                  Comment

                  • Cor Ligthert [MVP]

                    #10
                    Re: keep program running

                    Do
                    Application.doe vents
                    threading.threa d.sleep(millise conds) ' something as 3000
                    Loop

                    This will stop the program if the user clickes the close box in top of the
                    form.
                    If you let it always go it will eat your complete processing time.

                    I hope this helps,

                    Cor


                    "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
                    news:uRZssEzVGH A.1344@TK2MSFTN GP15.phx.gbl...[color=blue]
                    >I am trying to run process that fires at regular intervals based on a
                    >timer. I tried to use a Windows service to do this but found that it ran in
                    >a different account than did the user so it had no knowledge of things like
                    >key strokes, etc that the user was making.
                    >
                    > Here is the sub main code. All of the work is actually done in the timer
                    > code.
                    >
                    > Public Sub Main()
                    >
                    > MyTimer1.Interv al = 50
                    > MyTimer1.Enable d = True
                    > MyTimer2.Interv al = 10000
                    > MyTimer2.Enable d = True
                    > 'MsgBox("starte d") 'this will keep the program running if not
                    > clicked on
                    > 'here is another method of keeping the program running to allow the
                    > timers to fire.
                    > Do While 3 <> 2
                    >
                    > Loop
                    >
                    > End Sub
                    >
                    >
                    > "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
                    > news:eSHhK3tVGH A.5012@TK2MSFTN GP10.phx.gbl...[color=green]
                    >> William,
                    >>
                    >> As you tell it there is not any code needed. Can you rephrase.
                    >>
                    >> Probably it is a loop with a threading.threa d.sleep in it.
                    >>
                    >> However there your text does not tell how your program stops.
                    >>
                    >> Cor
                    >>
                    >> "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
                    >> news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...[color=darkred]
                    >>> If I have a Windows application with no form--only a module that starts
                    >>> with sub main and which has a system timer, in the elapsed event of
                    >>> which I want to run some code, how can I keep this program from running
                    >>> through the sub main code and then closing without ever firing the
                    >>> timer?
                    >>>
                    >>> I can put
                    >>>
                    >>> Do While 3 <> 2
                    >>>
                    >>> Loop
                    >>>
                    >>> at the end of the sub main code and that seems to work, but there must
                    >>> be a better way.
                    >>>[/color]
                    >>
                    >>[/color]
                    >
                    >[/color]


                    Comment

                    • William LaMartin

                      #11
                      Re: keep program running

                      There is not form--only a module--so there is no application object.

                      "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
                      news:OUE0UQzVGH A.1204@TK2MSFTN GP12.phx.gbl...[color=blue]
                      > Do
                      > Application.doe vents
                      > threading.threa d.sleep(millise conds) ' something as 3000
                      > Loop
                      >
                      > This will stop the program if the user clickes the close box in top of the
                      > form.
                      > If you let it always go it will eat your complete processing time.
                      >
                      > I hope this helps,
                      >
                      > Cor
                      >
                      >
                      > "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
                      > news:uRZssEzVGH A.1344@TK2MSFTN GP15.phx.gbl...[color=green]
                      >>I am trying to run process that fires at regular intervals based on a
                      >>timer. I tried to use a Windows service to do this but found that it ran
                      >>in a different account than did the user so it had no knowledge of things
                      >>like key strokes, etc that the user was making.
                      >>
                      >> Here is the sub main code. All of the work is actually done in the timer
                      >> code.
                      >>
                      >> Public Sub Main()
                      >>
                      >> MyTimer1.Interv al = 50
                      >> MyTimer1.Enable d = True
                      >> MyTimer2.Interv al = 10000
                      >> MyTimer2.Enable d = True
                      >> 'MsgBox("starte d") 'this will keep the program running if not
                      >> clicked on
                      >> 'here is another method of keeping the program running to allow
                      >> the timers to fire.
                      >> Do While 3 <> 2
                      >>
                      >> Loop
                      >>
                      >> End Sub
                      >>
                      >>
                      >> "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
                      >> news:eSHhK3tVGH A.5012@TK2MSFTN GP10.phx.gbl...[color=darkred]
                      >>> William,
                      >>>
                      >>> As you tell it there is not any code needed. Can you rephrase.
                      >>>
                      >>> Probably it is a loop with a threading.threa d.sleep in it.
                      >>>
                      >>> However there your text does not tell how your program stops.
                      >>>
                      >>> Cor
                      >>>
                      >>> "William LaMartin" <lamartin@tampa bay.rr.com> schreef in bericht
                      >>> news:e7jLSQsVGH A.4608@tk2msftn gp13.phx.gbl...
                      >>>> If I have a Windows application with no form--only a module that starts
                      >>>> with sub main and which has a system timer, in the elapsed event of
                      >>>> which I want to run some code, how can I keep this program from running
                      >>>> through the sub main code and then closing without ever firing the
                      >>>> timer?
                      >>>>
                      >>>> I can put
                      >>>>
                      >>>> Do While 3 <> 2
                      >>>>
                      >>>> Loop
                      >>>>
                      >>>> at the end of the sub main code and that seems to work, but there must
                      >>>> be a better way.
                      >>>>
                      >>>
                      >>>[/color]
                      >>
                      >>[/color]
                      >
                      >[/color]


                      Comment

                      • Herfried K. Wagner [MVP]

                        #12
                        Re: keep program running

                        "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=blue][color=green][color=darkred]
                        >>> If I have a Windows application with no form--only a module that starts
                        >>> with sub main and which has a system timer, in the elapsed event of
                        >>> which I want to run some code, how can I keep this program from running
                        >>> through the sub main code and then closing without ever firing the
                        >>> timer?[/color]
                        >>
                        >> 'Application.Ru n()'.[/color]
                        >
                        >I do not understand your answer.[/color]

                        Simply call 'Application.Ru n' at the end of your 'Sub Main'. This will
                        prevent the Windows Application from terminating when the code inside 'Sub
                        Main' has been executed.

                        --
                        M S Herfried K. Wagner
                        M V P <URL:http://dotnet.mvps.org/>
                        V B <URL:http://classicvb.org/petition/>

                        Comment

                        • Herfried K. Wagner [MVP]

                          #13
                          Re: keep program running

                          "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=blue]
                          >I am trying to run process that fires at regular intervals based on a
                          >timer.[/color]

                          Which timer class are you using? Note that 'System.Windows .Forms.Timer' is
                          only intended for use on a form.

                          --
                          M S Herfried K. Wagner
                          M V P <URL:http://dotnet.mvps.org/>
                          V B <URL:http://classicvb.org/petition/>

                          Comment

                          • William LaMartin

                            #14
                            Re: keep program running

                            Public WithEvents MyTimer1 As New System.Timers.T imer is what I am using.

                            "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                            news:uyLqkc1VGH A.5460@TK2MSFTN GP11.phx.gbl...
                            [color=blue]
                            > "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=green]
                            >>I am trying to run process that fires at regular intervals based on a
                            >>timer.[/color]
                            >
                            > Which timer class are you using? Note that 'System.Windows .Forms.Timer'
                            > is only intended for use on a form.
                            >
                            > --
                            > M S Herfried K. Wagner
                            > M V P <URL:http://dotnet.mvps.org/>
                            > V B <URL:http://classicvb.org/petition/>[/color]


                            Comment

                            • William LaMartin

                              #15
                              Re: keep program running

                              There is no application object if I only have a module in my project as best
                              I can tell.

                              "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                              news:euwo$b1VGH A.1756@TK2MSFTN GP11.phx.gbl...[color=blue]
                              > "William LaMartin" <lamartin@tampa bay.rr.com> schrieb:[color=green][color=darkred]
                              >>>> If I have a Windows application with no form--only a module that starts
                              >>>> with sub main and which has a system timer, in the elapsed event of
                              >>>> which I want to run some code, how can I keep this program from running
                              >>>> through the sub main code and then closing without ever firing the
                              >>>> timer?
                              >>>
                              >>> 'Application.Ru n()'.[/color]
                              >>
                              >>I do not understand your answer.[/color]
                              >
                              > Simply call 'Application.Ru n' at the end of your 'Sub Main'. This will
                              > prevent the Windows Application from terminating when the code inside 'Sub
                              > Main' has been executed.
                              >
                              > --
                              > M S Herfried K. Wagner
                              > M V P <URL:http://dotnet.mvps.org/>
                              > V B <URL:http://classicvb.org/petition/>[/color]


                              Comment

                              Working...