public HandlerDIR(Handler handler)
 {
     this.handler = handler;
     gchandles    = new List <GCHandle>();
     if (handler != null)
     {
         HandlerSet handlerSet = new HandlerSet();
         if (handler.onRecognition != null)
         {
             OnRecognitionDIRDelegate dir = new OnRecognitionDIRDelegate(OnRecognition);
             gchandles.Add(GCHandle.Alloc(dir));
             handlerSet.onRecognition = Marshal.GetFunctionPointerForDelegate(dir);
         }
         if (handler.onAlert != null)
         {
             OnAlertDIRDelegate dir = new OnAlertDIRDelegate(OnAlert);
             gchandles.Add(GCHandle.Alloc(dir));
             handlerSet.onAlert = Marshal.GetFunctionPointerForDelegate(dir);
         }
         dirUnmanaged = PXCMSpeechRecognition_AllocHandlerDIR(handlerSet);
     }
 }
 public HandlerDIR(Handler handler)
 {
     this.handler = handler;
     gchandles = new List<GCHandle>();
     if (handler != null)
     {
         HandlerSet handlerSet = new HandlerSet();
         if (handler.onRecognition != null)
         {
             OnRecognitionDIRDelegate dir = new OnRecognitionDIRDelegate(OnRecognition);
             gchandles.Add(GCHandle.Alloc(dir));
             handlerSet.onRecognition = Marshal.GetFunctionPointerForDelegate(dir);
         }
         if (handler.onAlert != null)
         {
             OnAlertDIRDelegate dir = new OnAlertDIRDelegate(OnAlert);
             gchandles.Add(GCHandle.Alloc(dir));
             handlerSet.onAlert = Marshal.GetFunctionPointerForDelegate(dir);
         }
         dirUnmanaged = PXCMSpeechRecognition_AllocHandlerDIR(handlerSet);
     }
 }