C#中 Process的扩展类ProcessExtensions(2)

/// <summary>
        /// Get information of the process name
        /// </summary>
        /// <param>Process to get information about</param>
        /// <returns></returns>
        public static string GetInformation(this Process Process)
        {
            return Process.ProcessName;
        }

/// <summary>
        /// Gets information about all processes and returns it in  string
        /// </summary>
        /// <param>Processes to get information about</param>
        /// <returns>string</returns>
        public static string GetInformation(this IEnumerable<Process> Processes)
        {
            StringBuilder Builder = new StringBuilder();
            Processes.ForEach(x => Builder.Append(x.GetInformation()));
            return Builder.ToString();
        }

#endregion

#endregion

#region Private Static Functions

/// <summary>
        /// Kills a process asyncronously
        /// </summary>
        /// <param>Name of the process to kill</param>
        /// <param>Amount of time until the process is killed</param>
        private static void KillProcessAsyncHelper(Process Process, int TimeToKill)
        {
            if (TimeToKill > 0)
                Thread.Sleep(TimeToKill);
            Process.Kill();
        }

#endregion
    }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydspw.html