Вниз
Скачать: CL | DM;

QueryEndSession - как чуток подождать?..   Найти похожие ветки 

 
Vladimyr ©   (2005-03-16 17:03) [0]

Всем добрый день, посоветуйте, как правильно использовать
обработчик OnQueryEndSession?

    Мне нужно притормозить завершение работы Windows XP
на несколько секунд, пока моя программа доделает свои дела ;)
С большим удивлением заметил, что это не так-то просто!
Установка в обработчике Accept := false полностью
прерывает процесс Shutdown"а, а использование цикла ожидания типа

while Some_Custom_Flag do Sleep (100); Accept := true;

не приостанавливает выполнение процесса - программа всё равно
закрывается!

    Прервать Shutdown, а потом инициировать его самому ещё раз,
непросто по причине того, тогда нужно как-то определить, что же
это было - выключение компьютера или перезагрузка.


 
thaddy   (2005-03-16 17:51) [1]

You can use an Observer thread to monitor if your program has finished. If the thread ends after waitforsingleobject on the main thread, you can set accept to true.


 
Vladimyr ©   (2005-03-16 18:58) [2]

Thank, Thaddy, but how can I stop and wait inside OnQueryEndSession procedure?
I shouldn"t return neither true nor false to the system till the main thread is finished!


 
thaddy   (2005-03-16 19:48) [3]

Use an API event object on your task. That"s how I do it.


 
Vladimyr ©   (2005-03-16 20:34) [4]

As I suspected :)
Thank you a lot, I"ll try...


 
Vladimyr ©   (2005-03-17 00:40) [5]

Unfortunately, it doesn"t work.  :(

WaitForSingleObject is waiting,
but the program is being closed in spite of it,
if I do not return Accept := false.

Otherwise, if I do, the shutdown process is stopped
and needs to be started one more time.

What I can"t do programmely since I don"t know
if it was restarting the system or turning off the PC.

So, all the same...



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.03 c
2-1129632747
ne0n
2005-10-18 14:52
2005.11.13
DWORD--->String


2-1129474903
quadronik
2005-10-16 19:01
2005.11.13
присвоение даты в maskedit.text


14-1129731119
ArtemESC
2005-10-19 18:11
2005.11.13
Старый добрый Turbo Pascal


14-1130049230
SergP.
2005-10-23 10:33
2005.11.13
Посоветуйте стабильный ICQ-клиент


1-1129740924
Rav
2005-10-19 20:55
2005.11.13
"Глобальный" перехват исключений




   Наверх