-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumberCounter.cs
More file actions
49 lines (42 loc) · 1.28 KB
/
NumberCounter.cs
File metadata and controls
49 lines (42 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ThreadExample
{
public class NumberCounter
{
public void CounterUp()
{
try {
Console.WriteLine("Count up is started------>");
Thread.Sleep(1000);
for (int i = 1; i <= 100; i++)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write($"i = {i}, ");
//Thread.Sleep(100);
}
Thread.Sleep(1000);
Console.WriteLine("Count up is stopped->");
} catch(ThreadInterruptedException ex)
{
Console.WriteLine("Count up thread is interrupt.");
}
}
public void CounterDown()
{
Console.WriteLine("Count down is started------>");
Thread.Sleep(1000);
for (int j = 100; j >= 1; j--)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write($"j = {j}, ");
//Thread.Sleep(100);
}
Thread.Sleep(1000);
Console.WriteLine("Count down is stopped->");
}
}
}