1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
using System; using System.Management.Automation; // Windows PowerShell namespace. namespace PowerSh { class PowerSh { static void Main(string[] args) { PowerShell ps = PowerShell.Create(); ps.AddScript("[System.Console]::Beep(261,500);[System.Console]::Beep(293,500);[System.Console]::Beep(329,500);[System.Console]::Beep(349,500);[System.Console]::Beep(391,500);[System.Console]::Beep(440,500);[System.Console]::Beep(493,500)"); IAsyncResult result = ps.BeginInvoke(); // do something else until execution has completed. // this could be sleep/wait, or perhaps some other work while (result.IsCompleted == false) { } Console.WriteLine("Fin!"); } // End Main. } // End PowerSh. } |