
arrays / pointers in managed classes
I used to do this in VC++6, but now I'm kinda stuck:
[class member]
HANDLE Handles[2];
[in member function]
WaitForMultipleObjects(2, Handles, FALSE, INFINITE);
This doesn't work in a managed class: apparently an array name, even
with an explicit __nogc in the array declaration, is no longer the
same as a pointer to its first element?
HANDLE Handles __nogc [2];
WaitForMultipleObjects(2, Handles, FALSE, INFINITE);
error C2664: 'WaitForMultipleObjects' : cannot convert parameter 2
from 'HANDLE [2]' to 'const HANDLE * '
And when I write
WaitForMultipleObjects(2, &Handles[0], FALSE, INFINITE);
the compiler tells me that &Handles[0] is a __gc pointer, despite the
__nogc in the array declaration ???
Do I really have to resort to allocating memory for the array myself,
like this?
HANDLE __nogc *Handles;
Handles = (HANDLE __nogc *)malloc(2 * sizeof(HANDLE));
Handles[0] = ...
Handles[1] = ...
WaitForMultipleObjects(...);
free(Handles);
Or won't this work either?