Yes, I'm sorry, these are win32 events. My conversion follows
The three errors I get are
1)Dim unEventPermissions As UInt32 = 2031619
It says error converting 2031619 to a UInt32
2) OpenEvent was not found in dll Kernel32.dll
3) IntPtr.Zero = hEvent
operator = is not defined for IntPtr
Here it is:
Namespace CSharpEventSink
' <summary>
' Summary description for Class1.
' </summary>
Class Class1
'OPEN EVENT
Private Declare Function OpenEvent Lib "Kernel32.dll" (ByVal
dwDesiredAccess As UInt32, ByVal bInheritHandle As Boolean, ByVal lpName As
String) As IntPtr
' <summary>
' The main entry point for the application.
' </summary>
<STAThread()> _
Private Shared Sub Main(ByVal args() As String)
Dim unEventPermissions As UInteger = 2031619
' Same as EVENT_ALL_ACCESS value in the Win32 realm
Dim hEvent As IntPtr = IntPtr.Zero
' Get a handle to the Win32 Event. The name, "MfcEventSource",
is known in advance
hEvent = OpenEvent(unEventPermissions, False, "MfcEventSource")
If (IntPtr.Zero = hEvent) Then
Console.WriteLine("OpenEvent failed")
Return
' Exit
End If
' Create an AutoResetEvent object to wrap the handle we got from
OpenEvent
Dim arEvent As AutoResetEvent = New AutoResetEvent(False)
arEvent.Handle = hEvent
' Set the Handle to the event from
Dim waitHandles() As WaitHandle
'Put it in our array for WaitAny()
waitHandles(0) = arEvent
Dim bDone As Boolean = False
While Not bDone
Console.WriteLine("Top of while")
Dim waitResult As Integer = WaitHandle.WaitAny(waitHandles,
2000, False)
' For timeout, just loop and wait again
If (waitResult = WaitHandle.WaitTimeout) Then
Console.WriteLine(" WaitAny timed out.")
ElseIf (0 = waitResult) Then
Console.WriteLine("0 == waitResult. Yippee !!!")
' Do Something
ElseIf (1 = waitResult) Then
Console.WriteLine("1 == waitResult !!!")
' Do Something Else
Else
Console.WriteLine("Error else")
End If
End While
End Sub
End Class
End Namespace
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Jon wrote: Thank you. Apparently, this article below demonstrates how it should be
done, but it's in C#, and I can't get it converted correctly.
http://www.codeproject.com/csharp/interopevents.asp
Ah, what we're talking about here aren't .NET events, they are Win32
events. So really, since C# and VB.NET both interop with Win32 in a
very similar way, it's just a translation problem. Let's see your VB
translation :)
--
Larry Lard
Replies to group please