public override string Execute(string id, string message) { IEvent notif; try { notif = new TEvent().SplitMessage(message); } catch { return("Wrong format. If you want to create notification, write like: \"e create : DD.MM.YYYY HH.MM - event_name\""); } if (notif.NextTime < (DateTime.UtcNow + rusTime)) { return("This time has expired."); } Action <ITurnContext <IMessageActivity>, TEvent> Send = (client, notification) => { if (int.TryParse(id, out int _id)) { client.SendActivityAsync(MessageFactory.Text(notification.Description)).GetAwaiter().GetResult(); } }; tokenSource.Cancel(); tokenSource = new CancellationTokenSource(); token = tokenSource.Token; lock (allReminds) { allReminds.Add(notif.NextTime, notif); db.AddEvent((TEvent)notif); } if (allReminds.Count == 1) { Task.Factory.StartNew(() => SendReminds(token, bot, Send, id)); } return(""); }