Esempio n. 1
0
        private void ButtonBuild_Click(object sender, EventArgs e)
        {
            if (_login)
            {
                switch (buttonBuild.Text)
                {
                case "Start Building":
                {
                    if (threadBuild != null)
                    {
                        if (threadBuild.IsAlive)
                        {
                            threadBuild.Abort();
                        }
                    }

                    travian.cts      = new CancellationTokenSource();
                    buttonBuild.Text = "Stop Building";
                    threadBuild      = new Thread(() =>
                        {
                            if (travian.BuildBuildings())
                            {
                                Bot.Log("Started building.", Color.Black);
                            }
                        });
                    threadBuild.Start();
                    break;
                }

                case "Stop Building":
                {
                    buttonBuild.Text = "Start Building";
                    travian.cts.Cancel();

                    if (threadBuild != null)
                    {
                        if (threadBuild.IsAlive)
                        {
                            threadBuild.Abort();
                        }
                    }
                    break;
                }
                }
            }
            else
            {
                Bot.Log("First login!", Color.Red);
            }
        }