/// <summary> /// Кнопка остановки сервера /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Stop_Click(object sender, EventArgs e) { btn_Stop.Enabled = false; btn_Start.Enabled = true; btn_StartGen.Enabled = true; btn_StartPredGen.Enabled = true; Action StopCommander = () => { commander.Stop(); }; Task TasksStopCommander = Task.Factory.StartNew(StopCommander); Action StopHandlerLog = () => { HandlerLogs.Stop(); }; Task TasksStopHandlerLogs = Task.Factory.StartNew(StopHandlerLog); }