When I write a program about IO completion port in Windows Vista, the first sample didn't work and the GetQueuedCompletionStatus() can not get any OVERLAPPED structures.
So I put the OVERLAPPED structure in global scope,and it works amazingly. Why is that?
CODE1:
int main()
{
OVERLAPPED o;
..
CreateIoCompletionPort(....);
for (int i = 0; i<10; i++)
{
WriteFile(..,&o);
OVERLAPPED* po;
GetQueuedCompletionStatus(..,&po);
}
}
CODE2:
OVERLAPPED o;
int main()
{
..
CreateIoCompletionPort(....);
for (int i = 0; i<10; i++)
{
WriteFile(..,&o);
OVERLAPPED* po;
GetQueuedCompletionStatus(..,&po);
}
}