public ThreadTask(threadAction mainAction)
 {
     myAction = () => {
         try
         {
             result = (T)(mainAction?.DynamicInvoke() ?? default(T));
             threadFinishedSuccessfully = true;
         }
         catch (Exception ex)
         {
             threadException = ex;
         }
     };
 }
 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);
     }
 }