G
Guest
Under WinCe Win32 we are experiencing problems with
"WaitForMultipleObjects(DWORD nCount, CONST HANDLE* lpHandles, BOOL fWaitAll,
DWORD dwMilliseconds )" being accessed from C#. It returns WAIT_FAILED and a
call to GetLastError() returns 0x80000005 (Invalid pointer).
We are trying to implement the function "WaitHandle.WaitAny(commands);"
which is not available in Netcf. We are using and extending the OpenNetcf
open source code.
The top call in its own thread looks like this--
ManualResetEvent [] commands = { channelEvent, killEvent };
int eventThatFired = 0;
bool keepGoing = true;
while (keepGoing)
{
eventThatFired = Core.WaitForMultipleObjectsJ1(commands,false);
The code we added in OpenNetcf looks like this--
[CLSCompliant(false)]
public static Int32 WaitForMultipleObjectsJ1(ManualResetEvent [] commands,
bool WaitForAll)
{
Int32 Len=commands.Length;
if(commands==null||Len==0)
{return 0;
}
IntPtr[] handles=new IntPtr[Len];
for(Int32 i=0;i<Len;i++)
{
handles=commands.Handle;
}
return
OpenNETCF.Threading.NativeMethods.WaitForMultipleObjects((uint)handles.Length, handles, WaitForAll, (uint)0xFFFFFFFF);
}
OpenNetcf uses this PInvoke--
[DllImport("coredll.dll", SetLastError=true)]
public static extern int WaitForMultipleObjects(uint nCount, IntPtr[]
lpHandles, bool fWaitAll, uint dwMilliseconds);
The symptom is that the call "
Core.WaitForMultipleObjectsJ1(commands,false);" returns immediately with a
return value of -1. This works back (using the GetLastError()) to the invalid
pointer error code.
Each ManualResetEvent instance does block properly if invoked usng the
WaitOne() method which is implemented in Netcf as below--
bool xbool=channelEvent.WaitOne();
Any help would be appreciated on this problem.
Thanks.
"WaitForMultipleObjects(DWORD nCount, CONST HANDLE* lpHandles, BOOL fWaitAll,
DWORD dwMilliseconds )" being accessed from C#. It returns WAIT_FAILED and a
call to GetLastError() returns 0x80000005 (Invalid pointer).
We are trying to implement the function "WaitHandle.WaitAny(commands);"
which is not available in Netcf. We are using and extending the OpenNetcf
open source code.
The top call in its own thread looks like this--
ManualResetEvent [] commands = { channelEvent, killEvent };
int eventThatFired = 0;
bool keepGoing = true;
while (keepGoing)
{
eventThatFired = Core.WaitForMultipleObjectsJ1(commands,false);
The code we added in OpenNetcf looks like this--
[CLSCompliant(false)]
public static Int32 WaitForMultipleObjectsJ1(ManualResetEvent [] commands,
bool WaitForAll)
{
Int32 Len=commands.Length;
if(commands==null||Len==0)
{return 0;
}
IntPtr[] handles=new IntPtr[Len];
for(Int32 i=0;i<Len;i++)
{
handles=commands.Handle;
}
return
OpenNETCF.Threading.NativeMethods.WaitForMultipleObjects((uint)handles.Length, handles, WaitForAll, (uint)0xFFFFFFFF);
}
OpenNetcf uses this PInvoke--
[DllImport("coredll.dll", SetLastError=true)]
public static extern int WaitForMultipleObjects(uint nCount, IntPtr[]
lpHandles, bool fWaitAll, uint dwMilliseconds);
The symptom is that the call "
Core.WaitForMultipleObjectsJ1(commands,false);" returns immediately with a
return value of -1. This works back (using the GetLastError()) to the invalid
pointer error code.
Each ManualResetEvent instance does block properly if invoked usng the
WaitOne() method which is implemented in Netcf as below--
bool xbool=channelEvent.WaitOne();
Any help would be appreciated on this problem.
Thanks.