void SetResult(UpdateContextSearchData searchData, UpdateContext newCtx) { var taskCompletionSource = searchData.TaskCompletionSource; var origCtx = searchData.CurrentUpdateContext; _searchBag.TryRemove(origCtx.ChatId.Identifier, origCtx.Bot.BotId); newCtx.ForceExit(); //Task will be continued with current thread context of readed UpdateContext object. //So we don`t need to start it with IExecutionManager. var t = taskCompletionSource.Task; if (t.IsCanceled || t.IsCompleted || t.IsFaulted) { return; } taskCompletionSource.SetResult(newCtx.Update); }