keeping it running...

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

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
 
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
 
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
 
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
 
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
 
Back
Top