Hi

I need to add pauses in-between processes in my app to give time to other
users/processes on the network. Is there a way to pass control to OS for a
specified time (say 15 seconds) to delay my app but at the same time not
blocking OS's processor cycles?

Thanks

Regards

Re: Pausing a process without holding OS by Armin

Armin
Sun Jul 13 10:45:43 CDT 2008

"John" <info@nospam.infovis.co.uk> schrieb
> Hi
>
> I need to add pauses in-between processes in my app to give time to
> other users/processes on the network. Is there a way to pass control
> to OS for a specified time (say 15 seconds) to delay my app but at
> the same time not blocking OS's processor cycles?

Threading.Thread.Sleep(15000)



If the thread has a UI, it's better not to Sleep because it locks the UI.
- Instead you should set a Timer and do whatever in 15 seconds
- Or, do whatever has to be done in another thread (including Sleep). Then I
also suggest not to sleep for 15 seconds but only max 1 second (for example)
in a loop in order to be able to react to cancel requests.


Armin


Re: Pausing a process without holding OS by surturz

surturz
Tue Jul 15 01:13:00 CDT 2008

Application.DoEvents() is probably the easiest way. You need to disable all
your controls so you don't get cascading events.

For example,
Me.Enabled = False
Application.DoEvents()
Me.Enabled = True


--
David Streeter
Synchrotech Software
Sydney Australia


"Armin Zingler" wrote:

> "John" <info@nospam.infovis.co.uk> schrieb
> > Hi
> >
> > I need to add pauses in-between processes in my app to give time to
> > other users/processes on the network. Is there a way to pass control
> > to OS for a specified time (say 15 seconds) to delay my app but at
> > the same time not blocking OS's processor cycles?
>
> Threading.Thread.Sleep(15000)
>
>
>
> If the thread has a UI, it's better not to Sleep because it locks the UI.
> - Instead you should set a Timer and do whatever in 15 seconds
> - Or, do whatever has to be done in another thread (including Sleep). Then I
> also suggest not to sleep for 15 seconds but only max 1 second (for example)
> in a loop in order to be able to react to cancel requests.
>
>
> Armin
>
>

Re: Pausing a process without holding OS by Armin

Armin
Tue Jul 15 04:42:59 CDT 2008

"SurturZ" <surturz@newsgroup.nospam> schrieb
> Application.DoEvents() is probably the easiest way. You need to
> disable all your controls so you don't get cascading events.
>
> For example,
> Me.Enabled = False
> Application.DoEvents()
> Me.Enabled = True


I wouldn't recommend DoEvents. I gave the reasons some weeks ago (can be
searched for). In (very) short: If I want to do two things at the same time,
I use two Threads. That's what they are made for. If I have two threads,
there is no reason to use DoEvents.


Armin