new void D_onReceiveMessages(EMMessage[] messages) { queue.QueueTask(() => { MainForm main = (MainForm)Application.OpenForms["MainForm"]; if (main.IsHandleCreated) { main.BeginInvoke(new EventHandler((s, e) => { main.refreshConversationList(); })); } }); }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { foreach (var task in sheduledTasks) { if (task.Ready()) { queue.QueueTask(task.Action); if (!task.Repeat) { sheduledTasks.Remove(task); } } } }
/// <summary> /// Начинает отслеживание реакций сообщения с картинкой. /// </summary> /// <param name="message">Отслеживаемое изображение</param> /// <param name="attachment">Картинка</param> private async Task ExecuteMessageTrack(DiscordMessage message, DiscordAttachment attachment) { var res = await queue.QueueTask(() => DownloadAndRecognizeImage(attachment)); if (res == null) { return; } Beatmapset banchoBeatmapset = res.Item1; Beatmap banchoBeatmap = res.Item2; // Ignore beatmap for several minutes foreach (var kvp in ignoreList) { if (DateTime.Now - kvp.Value > TimeSpan.FromMinutes(10)) { ignoreList.Remove(kvp.Key); } } if (ignoreList.ContainsKey(banchoBeatmap.id)) { logger.LogInformation($"Beatmap is in ignore list {banchoBeatmap.id}"); return; } ignoreList.Add(banchoBeatmap.id, DateTime.Now); // Contruct message DiscordEmbedBuilder embedBuilder = new DiscordEmbedBuilder(); TimeSpan mapLen = TimeSpan.FromSeconds(banchoBeatmap.total_length); DiscordEmoji banchoRankEmoji = emoji.RankStatusEmoji(banchoBeatmap.ranked); DiscordEmoji diffEmoji = emoji.DiffEmoji(banchoBeatmap.difficulty_rating); // Check gatari GBeatmap gBeatmap = gapi.TryGetBeatmap(banchoBeatmap.id); DiscordEmbed embed = utils.BeatmapToEmbed(banchoBeatmap, banchoBeatmapset, gBeatmap); await message.RespondAsync(embed : embed); }
public void Save() { queue.QueueTask(() => { try { db.SaveChanges(); } catch (DbEntityValidationException dbEx) { System.Console.WriteLine(dbEx.Message); } }); }
public void SendBroadcast(ushort destination, EmberApsFrame apsFrame, byte radius, byte messageTag, byte[] messageContents) { BackgroundQueue.QueueTask(() => Ezsp.SendBroadcast(destination, apsFrame, radius, messageTag, messageContents)); }
public void SendUnicast(EmberOutgoingMessageType type, ushort indexOrDestination, EmberApsFrame apsFrame, byte messageTag, byte[] messageContents) { BackgroundQueue.QueueTask(() => Ezsp.SendUnicast(type, indexOrDestination, apsFrame, messageTag, messageContents)); }