Exemple #1
0
        public void OnDisconnect(object sender, string reason, Bot bot)
        {
            lock (tasks)
            {
                while (tasks.Count > 0)
                {
                    Task task = tasks.Dequeue().task;

                    if (BotUtility.isTaskRunning(task))
                    {
                        task.Dispose();
                    }
                }
            }
            lock (subBots)
            {
                foreach (SubBot o in subBots.Values)
                {
                    if (o != null)
                    {
                        o.onDisconnect(sender, reason, bot);
                        o.onDisable(bot);
                        bot.form.Invoke(new Action(() =>
                        {
                            if (o.HasForm)
                            {
                                o.Form.Close();
                            }
                        }));
                    }
                }

                System.Threading.Thread.Sleep(500);
                subBots.Clear();
                bot.form.Invoke(new Action(() =>
                                           bot.form.subbotCheckedListBox.Items.Clear()
                                           ));
            }
        }