-
17-01-2010, 03:56 PM #1Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
làm sao để thời gian chạy song song với 1 hàm khác
e có 1 hàm đếm thừi gian như sau
Mã:{ int t = 90; Thread.Sleep(1000); while (t >= 1) { t--; Thread.Sleep(1000); Console.SetCursorPosition(55,1); Console.Write(t); }
Mã:public void Level1() { int j = 0; int l = 0; Console.Clear(); do { Console.SetCursorPosition(45, 1); Console.WriteLine("Marks: "); Console.SetCursorPosition(53, 1); Console.WriteLine(RecordPoints); Console.Clear(); int Chances=9; string Name = "countryside"; Console.SetCursorPosition(0, 1); Console.Write("Chances: "); Console.SetCursorPosition(10, 1); Console.WriteLine(Chances); Console.SetCursorPosition(45, 1); Console.WriteLine("Marks: "); Console.SetCursorPosition(0, 15); Console.WriteLine("Total Characters: {0}", Name.Length); string[] array = new string[Name.Length]; int so = 0; for (int i = 0; i < Name.Length; i++) { string len = Name.Substring(i, 1); array[so] = len; so++; } Random auto = new Random(); int value = auto.Next(so); //----------------------------------------/ int point = (50 - (Name.Length)); int diem = 0; for (int i = 0; i < Name.Length; i++) { if (array[i] == array[value]) { Console.SetCursorPosition(point, 5); Console.WriteLine(array[value]); diem++; } else { Console.SetCursorPosition(point, 5); Console.WriteLine("_"); } point += 2; } //----------------------/ j = (Name.Length) - diem; int Loop = 0; Console.SetCursorPosition(2, 10); Console.Write("Guess: "); while (Loop < Chances) { Console.SetCursorPosition(9, 10); string Guess = Console.ReadLine(); int point2 = (50 - (Name.Length)); for (int i = 0; i < Name.Length; i++) { if (Guess == array[value]) { break; } if (Guess == array[i]) { for (int y = i; y < Name.Length; y++) { if (Guess == array[y]) { Console.SetCursorPosition(point2, 5); Console.WriteLine(Guess); l++; RecordPoints++; Console.SetCursorPosition(53, 1); Console.WriteLine(RecordPoints); } point2 += 2; } break; } if (i == (Name.Length - 1)) { Loop++; int s = (Chances - Loop); Console.SetCursorPosition(10, 1); Console.WriteLine(s); if (Loop == Chances) { Console.Clear(); Console.SetCursorPosition(30, 3); Console.WriteLine("GAME OVER!"); } break; } point2 += 2; } if (j == l) { break; } } } while (j == l); }
em làm nó cứ 1 cái chạy trước 1 cái chạy sauView more random threads:
- Cách sử dụng chỉ một vài thư viện DLL của DEVEXPRESS
- Cách tra cứu các namspace , các lớp, các hàm trong C#?
- Lỗi SQL Server does not exist or access denied xử lý thế nào?
- Lấy dữ liệu từ Notepad vào listview
- thay đổi value trong TrackBar!!!!
- Vẽ 3 cạnh của tam giác bằng dấu "*"
- sắp xếp trong datagridview với C#?
- Sử dụng Tool Data và Common trong Devexpress?
- Câu lệnh swicht trong C# như thế nào??
- Lỗi: Interop type 'Microsoft.Office.Interop.Word.ApplicationClass' cannot be embedded?
-
17-01-2010, 04:00 PM #2Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Dùng multi-thread đi bạn [IMG]images/smilies/biggrin.png[/IMG]
-
17-01-2010, 04:19 PM #3Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
dùng như thế nào hả bạn
mình mới học nên chưa biết nhiều lắm
-
17-01-2010, 04:24 PM #4Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Mã:System.Threading.Thread thread = new System.Threading.Thread(<hàm cần chạy>);thread.Start();
-
17-01-2010, 04:45 PM #5Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
mọi người chỉ cụ thể hơn được ko ạ
em viết hàm main như sau
Mã:class Program { static void Main(string[] args) { GameVH obj = new GameVH(); obj.Guide(); obj.Name(); System.Threading.Thread thread = new System.Threading.Thread(Level1); thread.Start(); int t = 90; Thread.Sleep(1000); while (t >= 1) { t--; Thread.Sleep(1000); Console.SetCursorPosition(55, 1); Console.Write(t); } } }
-
17-01-2010, 05:18 PM #6Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Cái phương thức Level1() bạn đặt ở trong class Program luôn hả, có phải static ko. Còn phần này
Mã:int t = 90; Thread.Sleep(1000); while (t >= 1) { t--; Thread.Sleep(1000); Console.SetCursorPosition(55, 1); Console.Write(t); }
-
17-01-2010, 05:48 PM #7Junior Member
- Ngày tham gia
- Sep 2015
- Bài viết
- 0
Làm thế này nè bạn
Mã nguồn PHP:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;namespace ConsoleApplication2{ class Program { public static void Main(string[] args) { GameVH obj = new GameVH(); obj.Guide(); obj.Name(); Thread thread1 = new Thread(new ThreadStart(Level1)); thread1.Start(); int t = 90; Thread.Sleep(1000); while (t >= 1) { t--; Thread.Sleep(1000); Console.SetCursorPosition(55, 1); Console.Write(t); } } public static void Level1() { int j = 0; int l = 0; Console.Clear(); do { Console.SetCursorPosition(45, 1); Console.WriteLine("Marks: "); Console.SetCursorPosition(53, 1); Console.WriteLine(RecordPoints); Console.Clear(); int Chances = 9; string Name = "countryside"; Console.SetCursorPosition(0, 1); Console.Write("Chances: "); Console.SetCursorPosition(10, 1); Console.WriteLine(Chances); Console.SetCursorPosition(45, 1); Console.WriteLine("Marks: "); Console.SetCursorPosition(0, 15); Console.WriteLine("Total Characters: {0}", Name.Length); string[] array = new string[Name.Length]; int so = 0; for (int i = 0; i < Name.Length; i++) { string len = Name.Substring(i, 1); array[so] = len; so++; } Random auto = new Random(); int value = auto.Next(so); //----------------------------------------/ int point = (50 - (Name.Length)); int diem = 0; for (int i = 0; i < Name.Length; i++) { if (array[i] == array[value]) { Console.SetCursorPosition(point, 5); Console.WriteLine(array[value]); diem++; } else { Console.SetCursorPosition(point, 5); Console.WriteLine("_"); } point += 2; } //----------------------/ j = (Name.Length) - diem; int Loop = 0; Console.SetCursorPosition(2, 10); Console.Write("Guess: "); while (Loop < Chances) { Console.SetCursorPosition(9, 10); string Guess = Console.ReadLine(); int point2 = (50 - (Name.Length)); for (int i = 0; i < Name.Length; i++) { if (Guess == array[value]) { break; } if (Guess == array[i]) { for (int y = i; y < Name.Length; y++) { if (Guess == array[y]) { Console.SetCursorPosition(point2, 5); Console.WriteLine(Guess); l++; RecordPoints++; Console.SetCursorPosition(53, 1); Console.WriteLine(RecordPoints); } point2 += 2; } break; } if (i == (Name.Length - 1)) { Loop++; int s = (Chances - Loop); Console.SetCursorPosition(10, 1); Console.WriteLine(s); if (Loop == Chances) { Console.Clear(); Console.SetCursorPosition(30, 3); Console.WriteLine("GAME OVER!"); } break; } point2 += 2; } if (j == l) { break; } } } while (j == l); } }}
Hiện nay trên thị trường xuất hiện rất nhiều loại thuốc bôi tăng kích thước dương vật được lăng xê là có khả năng làm tăng kích cỡ dương vật của cánh mày râu. Tuy nhiên không phải loại thuốc nào cũng...
Thuốc tăng kích thước chim có tác...