none
Com Events to C#/.net RRS feed

  • Question

  • Hi,

    I've the good fortune to re-engineer an old legacy application. It mixes .net services with a VB front end GUI. 2 processes running on the same windows 10 host. 

    I need a document/tutorial that outilnes what goes on under the covers here. I do not know how the event fired in Visual Basic 6 is getting to the c# process running on the same machine. Ultimately this question is simply, is there a doc out there that explicitly outlines how events get from VB 6 to c# .net 3.5 processes. Ideally with code examples. Before I can toss the VB client out and replace it with something a little more modern, I need to get my head around what makes the existing code work and how "VB 6 events ---> C# .net 3.5 process" actually happen. Pictures are good for my little mind :) 


    Events are fired from the VB 6 GUI and handled in the c# (.net 3.5 service/process). I can see the c# service create events via

        [DllImport("kernel32.dll", CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto)]
        private static extern IntPtr CreateEvent(
          [In, Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(SecurityAttributesMarshaler))]
    			SecurityAttributes lpEventAttributes, // SA
          bool bManualReset,                    // reset type
          bool bInitialState,                   // initial state
          string lpName                         // object name
          );


    and wraps these in a ManagedEvent user type.  The handle returned by CreateEvent above is assigned into a ManualResetEvent's Handle which is subsequently added to a WaitHandle[] array. This array of handles (waitHandles) is monitored as below

     handle = WaitHandle.WaitAny(waitHandles);


    Can anybody direct me to meaningful docs that explain the how and the why of this. Its ooooold code I know. Can't find anything this specific on google

    Cheers,

    G

    Friday, October 13, 2017 11:33 AM

All replies