Ejemplo n.º 1
0
 public ThreadTask(threadAction mainAction)
 {
     myAction = () => {
         try
         {
             result = (T)(mainAction?.DynamicInvoke() ?? default(T));
             threadFinishedSuccessfully = true;
         }
         catch (Exception ex)
         {
             threadException = ex;
         }
     };
 }
Ejemplo n.º 2
0
 public static void fastThread(
     threadAction mainAction, Action <T> onSucess,
     Action <Exception> onThreadError,
     Action <Exception> onError)
 {
     try
     {
         ThreadTask <T> tt = new ThreadTask <T>(mainAction);
         tt.Start();
         if (tt.Join())
         {
             onSucess(tt.Result());
         }
         else
         {
             onThreadError(tt.GetError());
         }
     }
     catch (Exception ex)
     {
         onError(ex);
     }
 }