Ejemplo n.º 1
0
        public void joinHTTPThread(ThreadTask <OneTimeHTTPRequest.HTTPTaskResult> httpTask, bool killOnTokenError)
        {
            if (httpTask.Join())
            {
                OneTimeHTTPRequest.HTTPTaskResult httpTaskResult = httpTask.Result();
                switch (httpTaskResult.StatusCode)
                {
                case OneTimeHTTPRequest.HTTPResultEnum.SUCCESS:
                    checkItem("STEP_TOKEN");
                    log("Token sucess!!");
                    break;

                case OneTimeHTTPRequest.HTTPResultEnum.NOTOKEN_ERROR:
                    log("Error serving token\n" + httpTaskResult.description);
                    checkItem("STEP_ERROR");
                    break;

                case OneTimeHTTPRequest.HTTPResultEnum.TOKEN_AUTH_ERROR:
                    checkItem("STEP_TOKEN_ERROR");
                    log("Error that might risk the token, error: " +
                        httpTaskResult.description);
                    if (killOnTokenError)
                    {
                        log("closing all processes in user because token error");
                        new ProcessWatcher(LimitedChromeManager.Properties.Settings.Default.AllowedClientUsernames)
                        .KillAllUserProcesses(() => false);
                    }
                    else
                    {
                        log("Skipping closing apps due to config");
                    }
                    break;
                }
            }
            else
            {
                log("Error serving token\n" + httpTask.GetError());
                checkItem("STEP_ERROR");
            }
        }
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);
     }
 }