-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
124 lines (112 loc) · 2.77 KB
/
Program.cs
File metadata and controls
124 lines (112 loc) · 2.77 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Less6
{
/// <summary>
/// После рефлексии 6 задание
/// </summary>
class Program
{
static void Main(string[] args)
{
string stringa = new string('=', 30);
Console.WriteLine("Task Manager");
Process[] ps = Process.GetProcesses();
List<Process> list = new List<Process>();
for (;;)
{
int count = 0;
list.AddRange(ps);
Console.WriteLine(string.Format("Кол-во запущуенный {0}", list.Count));
Console.WriteLine(stringa);
list = (from x in list
orderby x.ProcessName
select x).ToList<Process>();
foreach (Process proc in list)
{
Console.WriteLine(string.Format("[{0}]\t{1}\t{2}\t{3}", new object[] { count, proc.Id, proc.ProcessName, proc.BasePriority }));
count++;
}
Console.Write("Ввести Id для закрытия = ");
string ids = Console.ReadLine();
int id = -1;
int.TryParse(ids, out id);
bool flag2 = id >= 0;
if (flag2)
{
Process procdel = list.FirstOrDefault((Process p) => p.Id == id);
bool flag3 = procdel != null;
if (flag3)
{
string tempName = procdel.ProcessName;
try
{
procdel.Kill();
Console.WriteLine(stringa);
Console.WriteLine("close " + tempName + " ");
Console.WriteLine(stringa);
list.Remove(procdel);
Console.WriteLine(string.Format("Кол-во запущуенный {0}", list.Count));
}
catch (InvalidOperationException)
{
Console.WriteLine("Process " + tempName + " not found!");
}
catch (Exception ex)
{
Console.WriteLine("Информация об ошибке: " + ex.StackTrace);
}
Console.WriteLine("Закрыть еще процессы или выйти из приложения, y/n ");
string sl = Console.ReadLine().ToLower();
bool flag = sl == "y";
bool flag4 = !flag;
if (flag4)
{
Environment.Exit(0);
}
}
}
else
{
Console.WriteLine("Введено не верно");
}
}
}
public Program()
{
}
[CompilerGenerated]
[Serializable]
sealed class __c
{
// Note: this type is marked as 'beforefieldinit'.
static __c()
{
}
public __c()
{
}
internal string _Main_b__0_0(Process x)
{
return x.ProcessName;
}
public static readonly Program.__c __9 = new Program.__c();
public static Func<Process, string> __9__0_0;
}
[CompilerGenerated]
sealed class __c__DisplayClass0_0
{
public __c__DisplayClass0_0()
{
}
internal bool _Main_b__1(Process p)
{
return p.Id == this.id;
}
public int id;
}
}
}