Two Dependant Processes
using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Threading; namespace TwoDependantProcesses { class Program { static void Main(string[] args) { Console.WriteLine("Press Enter to start Notepad (i.e. Process 1)"); Console.ReadKey(); Console.WriteLine("Starting Notepad..."); Thread t1 = new Thread(new ThreadStart(StartProcess1)); t1.Start(); while (t1.IsAlive == true) { System.Threading.Thread.Sleep(1000); } Console.WriteLine("Notepad Stopped. Starting MSPaint (i.e. Process 2)"); StartProcess2(); Console.WriteLine("MSPaint Stopped. Press Enter to Exit"); Console.ReadKey(); } static void StartProcess1() { Process proc = new Process(); proc.StartInfo.FileName = "Notepad.exe"; proc.Start(); Console.WriteLine("Notepad running..."); proc.WaitForExit(); } static void StartProcess2() { Process proc = new Process(); proc.StartInfo.FileName = "MSPaint.exe"; proc.Start(); Console.WriteLine("MSPaint running..."); proc.WaitForExit(); } } }
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment