Esempio n. 1
0
 /// <summary>
 /// Calls the method contained by MethodMessage.
 /// </summary>
 /// <remarks>This method is called by TMethodPump after GetMethodMessage is called.</remarks>
 public void MethodInvoke()
 {
     // you can not run this method again because the
     // signal is set that it has finished.
     if (IsCompleted)
     {
         throw new MethodExecutedException("Method already executed.");
     }
     try
     {
         try
         {
             ExceptionObject = null;
             AsyncState      = FEventMethod.DynamicInvoke(FArguments);
         }
         catch (Exception e)
         {
             // for some reason if the exeption is thrown in diynamicinvoke it has a
             // encapsulates the error
             ExceptionObject = e.InnerException;
         }
         OnAfterEvent?.Invoke(this, null);
         if (ExceptionObject != null)
         {
             throw ExceptionObject;
         }
     }
     finally
     {
         (AsyncWaitHandle as EventWaitHandle).Set();
         IsCompleted = true;
     }
 }
Esempio n. 2
0
 public void FireEvent(string msg)
 {
     OnBeforeEvent?.Invoke("Before Event is: " + DateTime.Now.ToString());
     System.Diagnostics.Debug.WriteLine("Before Event is: " + DateTime.Now.ToString());
     Task.Run(() => OnSyncLibEvent?.Invoke(msg));
     OnAfterEvent?.Invoke("After Event is: " + DateTime.Now.ToString());
     System.Diagnostics.Debug.WriteLine("After Event is: " + DateTime.Now.ToString());
 }