コード例 #1
0
        protected static void Write(string message)
        {
            try
            {
                Log.Warning("Attempting to write messsage to ServicePipe process");

                ServicePipe.Write(_Pipe, message);

                Log.Information("Successfully wrote messsage to ServicePipe process");
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
        }
コード例 #2
0
        protected string Read()
        {
            try
            {
                Log.Debug("Attempting to read message from ServicePipe process");

                string result = ServicePipe.Read(_pipe);

                Log.Debug(String.Format("Successfully read message: \"{0}\" from ServicePipe process", result));

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(exception);

                return(null);
            }
        }
コード例 #3
0
        protected static string Read()
        {
            try
            {
                Log.Information("Attempting to read message from ServicePipe process");

                string result = ServicePipe.Read(_Pipe);

                Log.Information("Successfully read message from ServicePipe process");

                return(result);
            }
            catch (Exception exception)
            {
                Log.Error(exception);

                return(null);
            }
        }
コード例 #4
0
        protected void Write(string message)
        {
            try
            {
                if (message.Length > 100)
                {
                    Log.Information(String.Format("Sending: \"{0}\" to ServicePipe process",
                                                  message.Substring(0, 100) + "...TRUNCATED"));
                }
                else
                {
                    Log.Information(String.Format("Sending: \"{0}\" to ServicePipe process", message));
                }

                ServicePipe.Write(_pipe, message);

                Log.Debug("Successfully wrote message to ServicePipe process");
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
        }
コード例 #5
0
        public static bool StopServer(bool forCurrentUserOnly)
        {
            try
            {
                System.Diagnostics.Process[] processes = GetServerProcesses(forCurrentUserOnly);

                if (processes != null && processes.Length > 0)
                {
                    foreach (Process t in processes)
                    {
                        try
                        {
                            t.Kill();
                        }
                        catch (Exception exception)
                        {
                            Log.Error(exception, false);
                        }
                    }

                    System.Threading.Thread.Sleep(500);
                }

                if (ServicePipe.IsServerRunning(forCurrentUserOnly))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception exception)
            {
                Log.Error(exception);

                return(false);
            }
        }