0

So the way I have my code set up loads the ChromeDriver before displaying the form. I need the driver to be global though so I am not sure how to handle this. Current code:

    public partial class Form1 : Form
    {
        DiscordSocketClient Client;
        IWebDriver driver = new ChromeDriver();
        string homeURL;
        string[,] betData = new string[15, 50];    
        int totalRows = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            cbDiscordChannel.SelectedIndex = 1;
            ConnectToDiscord();     
        }
user2668641
  • 39
  • 2
  • 4
  • What do you mean by 'global'? Static? You can put the assignment of `driver` inside `Form1_Load` then it starts after displaying the form. – Neijwiert Apr 05 '19 at 12:33
  • If I move driver to Form1_Load I can no long use/access it in other methods – user2668641 Apr 05 '19 at 12:39
  • You should look into the [singleton pattern](https://stackoverflow.com/questions/2155688/what-is-a-singleton-in-c) – Neijwiert Apr 05 '19 at 12:54

0 Answers0