private void Main_Load(object sender, EventArgs e) { HtmlLabel panel = new HtmlLabel(); panel.Name = "HtmlView"; panel.AutoSizeHeightOnly = true; HtmlPanel.Controls.Add(panel); HtmlPanel.Left = 0; HtmlPanel.Top = 0; HtmlPanel.Width = this.Width - SystemInformation.VerticalScrollBarWidth; HtmlPanel.Height = 621; HtmlPanel.VerticalScroll.Enabled = true; HtmlPanel.VerticalScroll.Visible = true; panel.Left = 0; panel.Top = 0; panel.Width = HtmlPanel.Width - SystemInformation.VerticalScrollBarWidth; panel.SendToBack(); HtmlPanel.BringToFront(); if (File.Exists(fbDataFile)) { string data = File.ReadAllText(fbDataFile); if (data.IndexOf("||") > -1 && data.IndexOf("||") < data.Length - 2) { fbEmail = data.Substring(0, data.IndexOf("||")); fbPassword = data.Substring(data.IndexOf("||") + 2); } } while (!Browser.IsBrowserInitialized) { Application.DoEvents(); } Task.Factory.StartNew(() => { logInToFB(); }); }