Gwupe.Agent.GwupeClientAppContext.RestartGwupeService C# (CSharp) Method

RestartGwupeService() public method

public RestartGwupeService ( ) : bool
return bool
        public bool RestartGwupeService()
        {
            Process restartProcess = null;
            try
            {
                restartProcess = new Process
                {
                    StartInfo = new ProcessStartInfo
                    {
                        UseShellExecute = true,
                        CreateNoWindow = true,
                        WindowStyle = ProcessWindowStyle.Hidden,
                        Verb = OsUtils.IsWinVistaOrHigher ? "runas" : "",
                        FileName = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) +
                                   "\\GwupeRestartService.exe"
                    }
                };
                restartProcess.Start();
                restartProcess.WaitForExit();

                if (restartProcess.ExitCode != 0)
                {
                    Logger.Error("Failed to restart GwupeService");
                    ThreadPool.QueueUserWorkItem(state =>
                        SubmitFaultReport(new FaultReport()
                        {
                            Subject = "Gwupe Service restart failure.",
                            UserReport = "Failed to restart GwupeService manually"
                        }));
                    return false;
                }
                else
                {
                    Logger.Info("Restarted Gwupe Service");
                    return true;
                }
            }
            catch (Exception e)
            {
                Logger.Error("Attempt to call Gwupe Service Restarter failed", e);
                ThreadPool.QueueUserWorkItem(state =>
                    SubmitFaultReport(new FaultReport()
                    {
                        Subject = "Gwupe Service restarter error",
                        UserReport = "Attempt to call Gwupe Service Restarter failed : " + e
                    }));
                return false;
            }
            finally
            {
                if (restartProcess != null)
                {
                    restartProcess.Close();
                }
            }
        }