Пример #1
0
        private static void Main(string[] args)
        {
            stopwatch = Stopwatch.StartNew();
            List<ProcessData> processData = new List<ProcessData>();
            using (KernelProcessSession session = new KernelProcessSession("TxSample"))
            using (ProcessTracker tracker = new ProcessTracker(session))
            {
                tracker.ProcessStopped += (o, e) => processData.Add(e.Data);

                Log("Starting session...");
                session.Start();
                Log("Running.");
                Thread.Sleep(TimeSpan.FromSeconds(10.0d));
                Log("Stopping session...");
                session.Stop();
                Log("Stopped.");
            }

            Log("Dumping event data...");

            foreach (ProcessData data in processData)
            {
                Console.WriteLine(
                    "Process ID {0} with image name '{1}' started at {2} and exited at {3} with code {4}.",
                    data.Id,
                    data.Name,
                    data.StartTime,
                    data.ExitTime,
                    data.ExitCode);
            }
        }
Пример #2
0
        private static void Main(string[] args)
        {
            stopwatch = Stopwatch.StartNew();
            List <ProcessData> processData = new List <ProcessData>();

            using (KernelProcessSession session = new KernelProcessSession("TxSample"))
                using (ProcessTracker tracker = new ProcessTracker(session))
                {
                    tracker.ProcessStopped += (o, e) => processData.Add(e.Data);

                    Log("Starting session...");
                    session.Start();
                    Log("Running.");
                    Thread.Sleep(TimeSpan.FromSeconds(10.0d));
                    Log("Stopping session...");
                    session.Stop();
                    Log("Stopped.");
                }

            Log("Dumping event data...");

            foreach (ProcessData data in processData)
            {
                Console.WriteLine(
                    "Process ID {0} with image name '{1}' started at {2} and exited at {3} with code {4}.",
                    data.Id,
                    data.Name,
                    data.StartTime,
                    data.ExitTime,
                    data.ExitCode);
            }
        }