private static extern ReturnCodes DataSourceEvent(
     [In, Out] Identity origin,
     [In, Out] Identity destination,
     DataGroups dataGroup,
     DataAttributeTypes dataAttributeType,
     Messages message,
     ref EventInterop eventReply);
        /// <summary>
        /// Constructor taking the datasourcemanager and the datasource which shall process a windows message
        /// </summary>
        /// <param name="dataSourceManager"></param>
        /// <param name="dataSource"></param>
        internal Event(DataSourceManager dataSourceManager, DataSource dataSource)
        {
            interopStruct = new EventInterop();
            interopStruct.WindowsMessagePointer = Marshal.AllocHGlobal(Marshal.SizeOf(windowsMessage));

            windowsMessage = new WindowsMsg();

            this.dataSourceManager = dataSourceManager;
            this.dataSource        = dataSource;
        }
 /// <summary>
 /// Routes a windowsmessage to the twaindriver which translate into a twainmessage
 /// </summary>
 /// <param name="applicationIdentity">Identity of the application</param>
 /// <param name="dataSourceIdentity">Identity of the datasource</param>
 /// <param name="eventMessage"></param>
 /// <returns>Reply of the twaindriver</returns>
 internal static ReturnCodes ProcessMessage(
     Identity applicationIdentity,
     Identity dataSourceIdentity,
     ref EventInterop eventMessage)
 {
     return(DataSourceEvent(
                applicationIdentity,
                dataSourceIdentity,
                DataGroups.Control,
                DataAttributeTypes.Event,
                Messages.ProcessEvent,
                ref eventMessage));
 }