Форум: "Система";
Текущий архив: 2003.10.06;
Скачать: [xml.tar.bz2];
Внизкак остановить поток? Найти похожие ветки
← →
Opryshok (2003-07-21 17:48) [0]помогите. вопрос таков:
я создаю поток
tempHndl: THandle;
...
tempHndl := BeginThread(nil, 0, Addr(WorkThread), PC, 0,tmpId);
поток не иммет условия выхода т.е.while true .....
как поtempHndl
мне остановить данный поток.
спасибо
← →
VMcL (2003-07-21 19:04) [1]>поток не имеет условия выхода т.е. while true
Замечательно. Тогда только TerminateThread.
← →
VMcL (2003-07-21 19:06) [2]P.S.
CloseHandle
не забудь.
← →
panov (2003-07-21 19:25) [3]Неправильно это. Условие поставь.
← →
Suntechnic (2003-07-22 05:12) [4]TerminateThread опасно. Надо быть абсолютно уверенным, что происходит в данный момент в потоке иначе можно очень сильно нарваться.
Условие выхода это идеальный вариант, но к сожаления не всегда применим.
← →
Opryshok (2003-07-22 21:24) [5]В том то и дело, что нету условия.
Функция WorkThread вызывает ReadDirectoryChangesW, которая "не выходит из себя".
Может подскажите как асинхронно запускать ReadDirectoryChangesW, а то я не могу понять. спасибо.
← →
Suntechnic (2003-07-22 21:56) [6]>Opryshok ©
Последних два параметра используются для асинхронного вызова.
← →
Igor__ (2003-07-23 09:45) [7]Остановить - SuspendThread.
Вырубить - TerminateThread
← →
Opryshok (2003-07-23 11:21) [8]
> Suntechnic
> Последних два параметра используются для асинхронного вызова
а как именно?
← →
Digitman (2003-07-23 11:46) [9]lpOverlapped
Points to an OVERLAPPED structure that supplies data to be used during asynchronous operation. Otherwise, this value is NULL. The Offset and OffsetHigh members of this structure are not used.
lpCompletionRoutine
Points to a completion routine to be called when the operation has been completed and the calling thread is in an alertable wait state. For more information about this completion routine, see FileIOCompletionRoutine.
Return Value
If the function succeeds, the return value is nonzero. For synchronous calls, this means that the operation succeeded. For asynchronous calls, this indicates that the operation was successfully queued.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
...
A call to ReadDirectoryChangesW can be completed synchronously or asynchronously. To specify asynchronous completion, open the directory with CreateFile as shown above, but additionally specify the FILE_FLAG_OVERLAPPED attribute in the dwFlagsAndAttributes parameter. Then specify an OVERLAPPED structure when you call ReadDirectoryChangesW.
Upon successful synchronous completion, the lpBuffer parameter is a formatted buffer and the number of bytes written to the buffer is available in lpBytesReturned. If the number of bytes transferred is zero, the buffer was too small to provide detailed information on all the changes that occurred in the directory or subtree. In this case, you should compute the changes by enumerating the directory or subtree.
For asynchronous completion, you can receive notification in one of three ways:
· Using the GetOverlappedResult function. To receive notification through GetOverlappedResult, do not specify a completion routine in the lpCompletionRoutine parameter. Be sure to set the hEvent member of the OVERLAPPED structure to a unique event.
· Using the GetQueuedCompletionStatus function. To receive notification through GetQueuedCompletionStatus, do not specify a completion routine in lpCompletionRoutine. Associate the directory handle hDirectory with a completion port by calling the CreateIoCompletionPort function.
· Using a completion routine. To receive notification through a completion routine, do not associate the directory with a completion port. Specify a completion routine in lpCompletionRoutine. This routine is called whenever the operation completes while the thread is in an alertable wait state. The hEvent member of the OVERLAPPED structure is not used by the system, so you can use it yourself.
что тебе здесь непонятно ? конкретно ?
Страницы: 1 вся ветка
Форум: "Система";
Текущий архив: 2003.10.06;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.008 c