private void button1_Click(object sender, EventArgs e) { if (!started) { button1.Text = "Pause"; var included = new StreamReader(File.OpenRead("categories.txt")).ReadToEnd().Split('\n').Select(a => a.Trim('\r')); var restAPIKey = ConfigurationManager.AppSettings["wooCommerceRestAPIKey"]; var restAPISecret = ConfigurationManager.AppSettings["wooCommerceRestAPISecret"]; var priceLowCap = ConfigurationManager.AppSettings["priceLowCap"]; var priceHighCap = ConfigurationManager.AppSettings["priceHighCap"]; var maxItemPerCategory = int.Parse(ConfigurationManager.AppSettings["maxItemPerCategory"]); var markUpPercentage = Double.Parse(ConfigurationManager.AppSettings["markUpPercentage"]); var usdtoMyrCurrencyRate = Double.Parse(ConfigurationManager.AppSettings["usdtoMyrCurrencyRate"]); var postTypeStr = ConfigurationManager.AppSettings["postAs"]; var productPauseDelay = int.Parse(ConfigurationManager.AppSettings["productPauseDelay"]); var productMinPriceAfterConvert = Double.Parse(ConfigurationManager.AppSettings["productMinPriceAfterConvert"]); var productBelowMinMarkup = Double.Parse(ConfigurationManager.AppSettings["productBelowMinMarkup"]); var loginPageAppearedPauseDelay = int.Parse(ConfigurationManager.AppSettings["loginPageAppearedPauseDelay"]); var restAPIUrl = ConfigurationManager.AppSettings["wooCommerceRestAPIUrl"]; bot = new BotRunner( restAPIUrl, postTypeStr, included, priceLowCap, priceHighCap, restAPIKey, restAPISecret, markUpPercentage, usdtoMyrCurrencyRate, productMinPriceAfterConvert, productBelowMinMarkup, maxItemPerCategory, productPauseDelay, new FormLogger(this, this.txtLog), new FormResultHandler(this, this.listView1), loginPageAppearedPauseDelay); thread = new Thread(() => { bot.Run(); }); thread.Start(); started = true; } else { if (!paused) { button1.Text = "Unpause"; bot.Pause(); paused = true; } else { button1.Text = "Pause"; bot.Resume(); paused = false; } } }