Home All Groups Group Topic Archive Search About
Author
3 Apr 2006 2:12 AM
William LaMartin
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.

Author
3 Apr 2006 3:58 AM
Vijay
Are you trying to run some process, that will execute a serious of steps?

VJ

Show quoteHide quote
"William LaMartin" <lamar***@tampabay.rr.com> wrote in message
news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>
Author
3 Apr 2006 3:01 PM
William LaMartin
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.

Show quoteHide quote
"Vijay" <vi***@msdiscussions.com> wrote in message
news:OaSPQLtVGHA.900@TK2MSFTNGP15.phx.gbl...
> Are you trying to run some process, that will execute a serious of steps?
>
> VJ
>
> "William LaMartin" <lamar***@tampabay.rr.com> wrote in message
> news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>>
>
>
Author
3 Apr 2006 5:18 AM
Cor Ligthert [MVP]
William,

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

Probably it is a loop with a threading.thread.sleep in it.

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

Cor

Show quoteHide quote
"William LaMartin" <lamar***@tampabay.rr.com> schreef in bericht
news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>
Author
3 Apr 2006 3:08 PM
William LaMartin
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.Interval = 50
        MyTimer1.Enabled = True
        MyTimer2.Interval = 10000
        MyTimer2.Enabled = True
        'MsgBox("started") '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


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:eSHhK3tVGHA.5012@TK2MSFTNGP10.phx.gbl...
> William,
>
> As you tell it there is not any code needed. Can you rephrase.
>
> Probably it is a loop with a threading.thread.sleep in it.
>
> However there your text does not tell how your program stops.
>
> Cor
>
> "William LaMartin" <lamar***@tampabay.rr.com> schreef in bericht
> news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>>
>
>
Author
3 Apr 2006 3:36 PM
Cor Ligthert [MVP]
Do
    Application.doevents
    threading.thread.sleep(milliseconds) ' 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


Show quoteHide quote
"William LaMartin" <lamar***@tampabay.rr.com> schreef in bericht
news:uRZssEzVGHA.1344@TK2MSFTNGP15.phx.gbl...
>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.Interval = 50
>        MyTimer1.Enabled = True
>        MyTimer2.Interval = 10000
>        MyTimer2.Enabled = True
>        'MsgBox("started") '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]" <notmyfirstn***@planet.nl> wrote in message
> news:eSHhK3tVGHA.5012@TK2MSFTNGP10.phx.gbl...
>> William,
>>
>> As you tell it there is not any code needed. Can you rephrase.
>>
>> Probably it is a loop with a threading.thread.sleep in it.
>>
>> However there your text does not tell how your program stops.
>>
>> Cor
>>
>> "William LaMartin" <lamar***@tampabay.rr.com> schreef in bericht
>> news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>>>
>>
>>
>
>
Author
3 Apr 2006 6:08 PM
William LaMartin
There is not form--only a module--so there is no application object.

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OUE0UQzVGHA.1204@TK2MSFTNGP12.phx.gbl...
> Do
>    Application.doevents
>    threading.thread.sleep(milliseconds) ' 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" <lamar***@tampabay.rr.com> schreef in bericht
> news:uRZssEzVGHA.1344@TK2MSFTNGP15.phx.gbl...
>>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.Interval = 50
>>        MyTimer1.Enabled = True
>>        MyTimer2.Interval = 10000
>>        MyTimer2.Enabled = True
>>        'MsgBox("started") '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]" <notmyfirstn***@planet.nl> wrote in message
>> news:eSHhK3tVGHA.5012@TK2MSFTNGP10.phx.gbl...
>>> William,
>>>
>>> As you tell it there is not any code needed. Can you rephrase.
>>>
>>> Probably it is a loop with a threading.thread.sleep in it.
>>>
>>> However there your text does not tell how your program stops.
>>>
>>> Cor
>>>
>>> "William LaMartin" <lamar***@tampabay.rr.com> schreef in bericht
>>> news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>>>>
>>>
>>>
>>
>>
>
>
Author
3 Apr 2006 7:45 PM
Herfried K. Wagner [MVP]
"William LaMartin" <lamar***@tampabay.rr.com> schrieb:
>I am trying to run process that fires at regular intervals based on a
>timer.

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/>
Author
3 Apr 2006 9:05 PM
William LaMartin
Public WithEvents MyTimer1 As New System.Timers.Timer is what I am using.

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:uyLqkc1VGHA.5460@TK2MSFTNGP11.phx.gbl...

> "William LaMartin" <lamar***@tampabay.rr.com> schrieb:
>>I am trying to run process that fires at regular intervals based on a
>>timer.
>
> 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/>
Author
3 Apr 2006 5:38 AM
Simmo
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/simplewindowsservice.asp


Troy



Show quoteHide quote
"William LaMartin" <lamar***@tampabay.rr.com> wrote in message
news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>
Author
3 Apr 2006 3:10 PM
William LaMartin
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.

Show quoteHide quote
"Simmo" <troy@NO-SPAMebswift.com> wrote in message
news:egQ3iDuVGHA.4952@TK2MSFTNGP09.phx.gbl...
> 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/simplewindowsservice.asp
>
>
> Troy
>
>
>
> "William LaMartin" <lamar***@tampabay.rr.com> wrote in message
> news:e7jLSQsVGHA.4608@tk2msftngp13.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.
>>
>
>
Author
3 Apr 2006 10:41 AM
Herfried K. Wagner [MVP]
"William LaMartin" <lamar***@tampabay.rr.com> schrieb:
> 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.Run()'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
3 Apr 2006 3:13 PM
William LaMartin
I do not understand  your answer.

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:OXbvkswVGHA.1536@TK2MSFTNGP15.phx.gbl...
> "William LaMartin" <lamar***@tampabay.rr.com> schrieb:
>> 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.Run()'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
3 Apr 2006 7:44 PM
Herfried K. Wagner [MVP]
"William LaMartin" <lamar***@tampabay.rr.com> schrieb:
>>> 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.Run()'.
>
>I do not understand  your answer.

Simply call 'Application.Run' 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/>
Author
3 Apr 2006 9:07 PM
William LaMartin
There is no application object if I only have a module in my project as best
I can tell.

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:euwo$b1VGHA.1756@TK2MSFTNGP11.phx.gbl...
> "William LaMartin" <lamar***@tampabay.rr.com> schrieb:
>>>> 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.Run()'.
>>
>>I do not understand  your answer.
>
> Simply call 'Application.Run' 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/>