Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Как сделать ожидание (аналог sleep())


Semu ©   (2002-05-30 13:33:00) 

Объясните чайнику, как сделать функцию ожидания (аналог sleep()),
что бы прога на время ожидания не грузила систему.


SeMu   (2002-05-30 14:01:00) [1]

Спасибо! Тема закрыта.


pin   (2002-05-30 13:51:00) [2]

))


pin   (2002-05-30 13:49:00) [3]

Sleep
The Sleep function suspends the execution of the current thread for at least the specified interval.

To enter an alertable wait state, use the SleepEx function.

VOID Sleep(
DWORD dwMilliseconds // sleep time
);


Parameters
dwMilliseconds
[in] Specifies the minimum time interval, in milliseconds, for which execution is to be suspended.
A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution.

A value of INFINITE indicates that the suspension should not time out.


Виктор Щербаков   (2002-05-30 13:46:00) [4]

he Sleep function suspends the execution of the current thread for a specified interval.

VOID Sleep(

DWORD dwMilliseconds // sleep time in milliseconds
);


Parameters

dwMilliseconds

Specifies the time, in milliseconds, for which to suspend execution. A value of zero causes the thread to relinquish the remainder of its time slice to any other thread of equal priority that is ready to run. If there are no other threads of equal priority ready to run, the function returns immediately, and the thread continues execution. A value of INFINITE causes an infinite delay.



Return Values

This function does not return a value.

Remarks

A thread can relinquish the remainder of its time slice by calling this function with a sleep time of zero milliseconds.
You have to be careful when using Sleep and DDE. If a thread creates any windows, it must process messages. DDE sends messages to all windows in the system. If you have a thread that uses a wait function with no time-out interval, the system will deadlock. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjects or MsgWaitForMultipleObjectsEx, rather than Sleep.


SeMu   (2002-05-30 13:44:00) [5]

Так где найти-то описание Sleep ?


Виктор Щербаков   (2002-05-30 13:43:00) [6]

SeMu (30.05.02 13:38)
Смотри Help|Windows SDK


NailS   (2002-05-30 13:40:00) [7]

А при sleep она не грузит, правда не реагирует на внешние раздражители.
Как альтернативу можно использовать WaitForMultipleObjects с таймаутом, при этом ждать события например на терминейт для потока.


SeMu   (2002-05-30 13:38:00) [8]

Будешь смеятся, но в HELPe по Дельфе, такой функции не нашел, я ж говорю, чайник. Где посмотреть то ?


Виктор Щербаков   (2002-05-30 13:35:00) [9]

А sleep чем не нравится?


Наверх

Титульная страница Поиск, карта сайта Написать письмо