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

keeping it running...

P: n/a
Hi,

When I create a program with a form, the form doesn't go away until I close
it somehow.
How is this done, can it also be done with a module or a class?

What I seek is this:

I wrote a program that runs in a sub Main().
At this moment I use a DO WHILE LOOP to have the program do something every
5 minutes.
I didn't use a timer, I used this:

do while stop = false
ac = now.addminutes(5)
do while now < ac
...do nothing
application.doEvents()
loop
...something
loop

The problem is, it slows down the pc.
I cannot use a timer because when the sub ends, the timer is disposed.

How can I use a timer and still not a form?
How do prevent the timer object to be disposed?
How can I stay within the sub Main without slowing down the pc (actually a
PDA)?

Please help.

rg,
Eric
Mar 14 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Eric,

In your current approach you can use
threading.thread.sleep(seconds)

What you want however seems a windowservice

To hide a form you can tell, me.hide or me.visible = false (assuming the
form is your mainclass).

I hope this gives some ideas

Cor

"Eric" <so*****@MicroZoft.com> schreef in bericht
news:44**********************@text.nova.planet.nl. ..
Hi,

When I create a program with a form, the form doesn't go away until I
close it somehow.
How is this done, can it also be done with a module or a class?

What I seek is this:

I wrote a program that runs in a sub Main().
At this moment I use a DO WHILE LOOP to have the program do something
every 5 minutes.
I didn't use a timer, I used this:

do while stop = false
ac = now.addminutes(5)
do while now < ac
...do nothing
application.doEvents()
loop
...something
loop

The problem is, it slows down the pc.
I cannot use a timer because when the sub ends, the timer is disposed.

How can I use a timer and still not a form?
How do prevent the timer object to be disposed?
How can I stay within the sub Main without slowing down the pc (actually a
PDA)?

Please help.

rg,
Eric

Mar 14 '06 #2

P: n/a
thanks, Cor,

In fact I choose not to use a form, because I don't have anything to put on.
My program is to get gps data from the VDO Dayton navigation computer by
serial connection and send them to a ASP website.
I use the notification balloon and icon to give the user a interaction (some
info and two link buttons).

I will give your first option a try.

Thanks!!
Eric

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:ug**************@TK2MSFTNGP12.phx.gbl...
Eric,

In your current approach you can use
threading.thread.sleep(seconds)

What you want however seems a windowservice

To hide a form you can tell, me.hide or me.visible = false (assuming the
form is your mainclass).

I hope this gives some ideas

Cor

"Eric" <so*****@MicroZoft.com> schreef in bericht
news:44**********************@text.nova.planet.nl. ..
Hi,

When I create a program with a form, the form doesn't go away until I
close it somehow.
How is this done, can it also be done with a module or a class?

What I seek is this:

I wrote a program that runs in a sub Main().
At this moment I use a DO WHILE LOOP to have the program do something
every 5 minutes.
I didn't use a timer, I used this:

do while stop = false
ac = now.addminutes(5)
do while now < ac
...do nothing
application.doEvents()
loop
...something
loop

The problem is, it slows down the pc.
I cannot use a timer because when the sub ends, the timer is disposed.

How can I use a timer and still not a form?
How do prevent the timer object to be disposed?
How can I stay within the sub Main without slowing down the pc (actually
a PDA)?

Please help.

rg,
Eric


Mar 14 '06 #3

P: n/a
Great, I got it working.
But...one question...

I did it like this:

Dim Th2 As Threading.Thread
Do While progStop = False
Th2 = New Threading.Thread(AddressOf nwTH)
Th2.Start()
Threading.Thread.Sleep(0)
Th2.Join()
Threading.Thread.Sleep(300000)
Application.DoEvents()
Loop

In the thread Th2 I do the stuff I need to do and I use Notification to
report it to the user.
While in sleep mode (5 minutes), the user can still open the Notification
Balloon and click on one of the two link buttons (settings and stop).
When he clicks on Stop, the variable progStop will be set tot true but the
application will still be sleeping.

Is it possible to force a thread to come out of sleep?

rg,
Eric

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:ug**************@TK2MSFTNGP12.phx.gbl...
Eric,

In your current approach you can use
threading.thread.sleep(seconds)

What you want however seems a windowservice

To hide a form you can tell, me.hide or me.visible = false (assuming the
form is your mainclass).

I hope this gives some ideas

Cor

"Eric" <so*****@MicroZoft.com> schreef in bericht
news:44**********************@text.nova.planet.nl. ..
Hi,

When I create a program with a form, the form doesn't go away until I
close it somehow.
How is this done, can it also be done with a module or a class?

What I seek is this:

I wrote a program that runs in a sub Main().
At this moment I use a DO WHILE LOOP to have the program do something
every 5 minutes.
I didn't use a timer, I used this:

do while stop = false
ac = now.addminutes(5)
do while now < ac
...do nothing
application.doEvents()
loop
...something
loop

The problem is, it slows down the pc.
I cannot use a timer because when the sub ends, the timer is disposed.

How can I use a timer and still not a form?
How do prevent the timer object to be disposed?
How can I stay within the sub Main without slowing down the pc (actually
a PDA)?

Please help.

rg,
Eric


Mar 15 '06 #4

P: n/a
Eric,

No, but are you sure that you should let that worker thread sleep. In my
opinion if that is true, than it is better to create a new worker thread and
let the other one die because it is ready.

Just my thought,

Cor

"Eric" <so*****@MicroZoft.com> schreef in bericht
news:44**********************@text.nova.planet.nl. ..
Great, I got it working.
But...one question...

I did it like this:

Dim Th2 As Threading.Thread
Do While progStop = False
Th2 = New Threading.Thread(AddressOf nwTH)
Th2.Start()
Threading.Thread.Sleep(0)
Th2.Join()
Threading.Thread.Sleep(300000)
Application.DoEvents()
Loop

In the thread Th2 I do the stuff I need to do and I use Notification to
report it to the user.
While in sleep mode (5 minutes), the user can still open the Notification
Balloon and click on one of the two link buttons (settings and stop).
When he clicks on Stop, the variable progStop will be set tot true but the
application will still be sleeping.

Is it possible to force a thread to come out of sleep?

rg,
Eric

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:ug**************@TK2MSFTNGP12.phx.gbl...
Eric,

In your current approach you can use
threading.thread.sleep(seconds)

What you want however seems a windowservice

To hide a form you can tell, me.hide or me.visible = false (assuming the
form is your mainclass).

I hope this gives some ideas

Cor

"Eric" <so*****@MicroZoft.com> schreef in bericht
news:44**********************@text.nova.planet.nl. ..
Hi,

When I create a program with a form, the form doesn't go away until I
close it somehow.
How is this done, can it also be done with a module or a class?

What I seek is this:

I wrote a program that runs in a sub Main().
At this moment I use a DO WHILE LOOP to have the program do something
every 5 minutes.
I didn't use a timer, I used this:

do while stop = false
ac = now.addminutes(5)
do while now < ac
...do nothing
application.doEvents()
loop
...something
loop

The problem is, it slows down the pc.
I cannot use a timer because when the sub ends, the timer is disposed.

How can I use a timer and still not a form?
How do prevent the timer object to be disposed?
How can I stay within the sub Main without slowing down the pc (actually
a PDA)?

Please help.

rg,
Eric



Mar 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.