Re: Почему WriteFileEx работает синхронно?
От: Sergey Chadov Россия  
Дата: 31.01.08 17:54
Оценка: 1 (1)
Здравствуйте, <Аноним>, Вы писали:

А>Всем привет!

А>В MSDN написано, что WriteFileEx работает только в асинхронном режиме, у меня же она работает почему-то в синхронном. Накатал примерчик:

WriteFileEx _может_ работать асинхронно. Но может не всегда.
Например, здесь написано:

One nuance of Windows' asynchronous I/O facility is that, depending on the API you use, you may or may not actually get an async operation back from the OS. IOW, although you request an operation to be carried out asynchronously, Windows may decide to run it synchronously and may hold up your API call until the operation completes. The OS always makes the final decision on whether an async I/O request is honored. What happens when Windows decides not to honor an async I/O request depends on the API. For ReadFile/WriteFile, they simply block until the operation completes and return TRUE. You have to check their return values and respond accordingly -- you can't write code that expects the operation to complete at some point in the future if the operation actually finished immediately. For ReadFileEx/WriteFileEx, the API returns TRUE regardless of whether the action is carried out synchronously or asynchronously. I'm not aware of an easy way to detect that an async I/O request has been carried out synchronously using ReadFileEx or WriteFileEx.



Мои экспериметны показывают, что поведение WriteFileEx сильно зависит не только от данных, но и от модели чипсета и версии дров и еще хрен знает чего.

Сам код не смотрел, может ошибка там, но вышенаписанное нужно иметь ввиду.
--
Sergey Chadov

... << RSDN@Home 1.2.0 alpha rev. 685>>
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.