Вниз
Скачать: 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.025 c
14-1128990736
X-Fi
2005-10-11 04:32
2005.11.13
Creative X-Fi Кто нибудь купил ? Поделитесь мнением ?


2-1130050454
beglec
2005-10-23 10:54
2005.11.13
Можно ли узнать имя процедуры.


1-1129874063
Layner
2005-10-21 09:54
2005.11.13
Как в цикле найти все виз. компаненты на форме


14-1129969400
dr Tr0jan
2005-10-22 12:23
2005.11.13
Гибрид TShellTreeView и TCheckbox


2-1129313241
картограф
2005-10-14 22:07
2005.11.13
StringGrid




   Наверх