static void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
            MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();
        }
예제 #2
0
        static void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();

            // OpenThenClose
            using (Process process = Process.Start("subl"))
            {
                // Display physical memory usage 5 times at intervals of 2 seconds.
                for (int i = 0; i < 5; i++)
                {
                    Console.WriteLine($"i:{i}");
                    if (!process.HasExited)
                    {
                        // Discard cached information about the process.
                        process.Refresh();
                        // Print working set to console.
                        Console.WriteLine($"Physical Memory Usage: {process.WorkingSet}");
                        // Wait 2 seconds.
                        Thread.Sleep(2000);
                    }
                    else
                    {
                        break;
                    }
                }

                Console.WriteLine($"process.HasExited: {process.HasExited}");
                // Close process by sending a close message to its main window.
                process.CloseMainWindow();
                // Free resources associated with process.
                process.Close();
            }
        }
예제 #3
0
        static void Main()
        {
            Console.WriteLine("0. Parent process begins. creates childrens...");
            Process parent = Process.GetCurrentProcess();
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            Parallel.For(0, 3, i =>
            {
                myProcess.OpenApplication(myFavoritesPath);
                myProcess.OpenWithArguments();
                myProcess.OpenWithStartInfo();
            }
                         );

            Console.WriteLine("Press ENTER to terminate the parent");
            Console.ReadKey();
            Console.WriteLine("X. Parent process terminated");
            //parent.WaitForExit();
        }