By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

keep program running

P: n/a
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.
Apr 3 '06 #1
Share this Question
Share on Google+
14 Replies


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

VJ

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:e7**************@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.

Apr 3 '06 #2

P: n/a
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" <la******@tampabay.rr.com> schreef in bericht
news:e7**************@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.

Apr 3 '06 #3

P: n/a
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" <la******@tampabay.rr.com> wrote in message
news:e7**************@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.

Apr 3 '06 #4

P: n/a
"William LaMartin" <la******@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/>

Apr 3 '06 #5

P: n/a
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" <vi***@msdiscussions.com> wrote in message
news:Oa*************@TK2MSFTNGP15.phx.gbl...
Are you trying to run some process, that will execute a serious of steps?

VJ

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:e7**************@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.


Apr 3 '06 #6

P: n/a
I do not understand your answer.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OX**************@TK2MSFTNGP15.phx.gbl...
"William LaMartin" <la******@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/>

Apr 3 '06 #7

P: n/a
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]" <no************@planet.nl> wrote in message
news:eS**************@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" <la******@tampabay.rr.com> schreef in bericht
news:e7**************@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.


Apr 3 '06 #8

P: n/a
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" <tr**@NO-SPAMebswift.com> wrote in message
news:eg**************@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/si...owsservice.asp
Troy

"William LaMartin" <la******@tampabay.rr.com> wrote in message
news:e7**************@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.


Apr 3 '06 #9

P: n/a
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" <la******@tampabay.rr.com> schreef in bericht
news:uR**************@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]" <no************@planet.nl> wrote in message
news:eS**************@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" <la******@tampabay.rr.com> schreef in bericht
news:e7**************@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.



Apr 3 '06 #10

P: n/a
There is not form--only a module--so there is no application object.

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OU**************@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" <la******@tampabay.rr.com> schreef in bericht
news:uR**************@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]" <no************@planet.nl> wrote in message
news:eS**************@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" <la******@tampabay.rr.com> schreef in bericht
news:e7**************@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.



Apr 3 '06 #11

P: n/a
"William LaMartin" <la******@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/>

Apr 3 '06 #12

P: n/a
"William LaMartin" <la******@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/>

Apr 3 '06 #13

P: n/a
Public WithEvents MyTimer1 As New System.Timers.Timer is what I am using.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uy**************@TK2MSFTNGP11.phx.gbl...
"William LaMartin" <la******@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/>

Apr 3 '06 #14

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

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eu**************@TK2MSFTNGP11.phx.gbl...
"William LaMartin" <la******@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/>

Apr 3 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.