Можно. Делал подобное. Работало одновременно без проблем. (+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено Val 22 июля 2003 г. 20:14
В ответ на: HID: ReadFile и WriteFile в разных потоках. Можно одновременно читать и писать? отправлено al 22 июля 2003 г. 16:31

Файл на HID крейтится в OVERLAPPED режиме.
Заводится по OVERLAPPED структуре на чтение и запись и event к каждой.
ReadFile и WriteFile могут вернуть FALSE. Тогда проверяется ошибка по GetLastError. Если ERROR_IO_PENDING -- все нормально, но процесс еще не завершен.
--------------------
If hFile was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the read operation starts at the offset specified in the OVERLAPPED structure and ReadFile may return before the read operation has been completed. In this case, ReadFile returns FALSE and the GetLastError function returns ERROR_IO_PENDING. This allows the calling process to continue while the read operation finishes. The event specified in the OVERLAPPED structure is set to the signaled state upon completion of the read operation.
--------------------

Ждется окончание процесса по GetOverlappedResult.
Если GetOverlappedResult возвращает FALSE. Проверяется ошибка по GetLastError. Если ERROR_IO_PENDING ( ERROR_IO_INCOMPLETE )-- все нормально, но процесс все еще не завершен.
И Т.Д.


--------------------
The results reported by the GetOverlappedResult function are those of the specified handle's last overlapped operation to which the specified OVERLAPPED structure was provided, and for which the operation's results were pending. A pending operation is indicated when the function that started the operation returns FALSE, and the GetLastError function returns ERROR_IO_PENDING. When an I/O operation is pending, the function that started the operation resets the hEvent member of the OVERLAPPED structure to the nonsignaled state. Then when the pending operation has been completed, the system sets the event object to the signaled state.

Specify a manual-reset event object in the OVERLAPPED structure. If an auto-reset event object is used, the event handle must not be specified in any other wait operation in the interval between starting the overlapped operation and the call to GetOverlappedResult. For example, the event object is sometimes specified in one of the wait functions to wait for the operation's completion. When the wait function returns, the system sets an auto-reset event's state to nonsignaled, and a subsequent call to GetOverlappedResult with the bWait parameter set to TRUE causes the function to be blocked indefinitely.

If the bWait parameter is TRUE, GetOverlappedResult determines whether the pending operation has been completed by waiting for the event object to be in the signaled state.
--------------------



Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru