Beispiel #1
0
        private void ProcessStarted(object sender, EventArrivedEventArgs e)
        {
            ManagementBaseObject targetInstance = (ManagementBaseObject)e.NewEvent.Properties["TargetInstance"].Value;
            string processName = targetInstance.Properties["Name"].Value.ToString();

            if (StopProcess && Independent.Name == processName)
            {
                notify(this, $"Killing {Dependent.Name} with {Independent.Name} start");
                Dependent.KillFirst();
            }
            else
            {
                notify(this, $"Starting {Dependent.Name} with {Independent.Name} start");
                Dependent.Start();
            }

            if (Dependent.Name == processName)
            {
                Dependent.Running = true;
            }
            if (Independent.Name == processName)
            {
                Independent.Running = true;
            }
            Console.WriteLine(String.Format("{0} process started", processName));
            bindUI();
        }