static void Main(string[] args) { //PerformanceCounter p = new PerformanceCounter("Processor", "% Processor Time", "_Total"); Thread[] threads = new Thread[GetProcessorCount()]; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(Loop); threads[i].Start(); } t1.Tick += On; t2.Tick += Off; t3.Tick += ChangeCPUUsage; t1.Start(); t3.Start(); }
//static Random r = new Random(); static void Main(string[] args) { Console.CursorVisible = false; Console.CursorTop = 24; Console.Write("Do you want to turning to NB mode? (y/n): "); while (true) { ConsoleKeyInfo cki = Console.ReadKey(true); if (cki.KeyChar == 'y' || cki.KeyChar == 'Y') { for (int i = post.Length - 1; i > 0; i--) { post[i] = post[i - 1]; } post[0] = "Turning to NB mode..."; post[1] = "Failed. Turning to Zhuangbi mode..."; break; } else if (cki.KeyChar == 'n' || cki.KeyChar == 'N') { break; } } p.Width = 25; p.PreName = ""; p.PreNameWidth = 0; p.PostName = post[flag]; p.PercentPrecision = 2; p.Line = 24; p.AutoRender = true; t.Tick += t_Tick; t.Start(); Console.ReadKey(true); }
public Form1() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; t1.Tick += t1_Tick; t2.Tick += t2_Tick; stopwatch.Start(); t1.Start(); t2.Start(); }
static void Main(string[] args) { timer.Tick += Timer_Tick; stopwatch.Start(); timer.Start(); //让Main方法进入死循环以确保程序不会退出。 while (true) { Thread.Sleep(0); } }
static void Main(string[] args) { Console.WindowHeight = 38; System.Console.Title = "Bad Apple!!"; BassNet.Registration("*****@*****.**", "2X93210140022"); Bass.BASS_Init(-1, 48000, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); Restart: ASCIIAnimation a = new ASCIIAnimation(35, 30, new StreamReader(Directory.GetCurrentDirectory() + "\\Bad Apple!!.txt")); music = Bass.BASS_StreamCreateFile(Directory.GetCurrentDirectory() + "\\Bad Apple!!.mp3", 0, 0, BASSFlag.BASS_DEFAULT); p = new ProgressBar(0, (int)Bass.BASS_ChannelGetLength(music)); p.Line = 36; p.PercentPrecision = 2; timer.Tick += timer_Tick; timer.Start(); Bass.BASS_ChannelPlay(music, false); a.Start(); while (true) { switch (Console.ReadKey(true).Key) { case ConsoleKey.Spacebar: switch (a.Status) { case PlayerStatus.Playing: Bass.BASS_ChannelPause(music); a.Pause(); break; case PlayerStatus.Paused: Bass.BASS_ChannelPlay(music, false); a.Start(); break; case PlayerStatus.Stopped: Bass.BASS_StreamFree(music); a.Dispose(); goto Restart; } break; case ConsoleKey.R: Bass.BASS_StreamFree(music); a.Dispose(); goto Restart; } } }
public void Start() { timer.Start(); Status = PlayerStatus.Playing; }
static void On(object sender, EventArgs e) { t1.Stop(); b = true; t2.Start(); }