Обработка нажатий клавишь с клавиатуры в консольном приложении C#
Всем привет, у меня есть потоковая обработка List, как мне сделать, что бы после нажатия любой клавиши с клавиатуры обработка заканчивалась ?
//private Dictionary<string, ushort> pairs = new Dictionary<string, ushort>();
private int countCharacter;
//private List<string> text;
private ConcurrentBag<string> text;
private bool isPressKey = false;
public string GetStatistics(
List<string> text,
int countTop = 10,
int countCharacter=3)
{
pairs.Clear();
//this.text = text;
this.text = new ConcurrentBag<string>(text);
this.countCharacter = countCharacter;
Start();
return gerResultOnString(countTop);
}
private void Start()
{
text.AsParallel()
.Where(str => str.Length >= countCharacter &&
Regex.IsMatch(str, "^[A-ZА-Я]+$")
&& !isPressKey)
.ForAll(str =>
{
//CheckPressKeyOnKeyBord();
checkNode(str);
});
}
Хочу прерывать работу метода Start() если была нажата любая клавиша с клавиатуры.