private void btnGetFile_Click(object sender, EventArgs e) { Dogs dogs = new Dogs(Utils.ConnectionString()); nafCount = dogs.GetMaxNAFNo(); excelFile = GetExcelFile(); if (string.IsNullOrEmpty(excelFile)) { string msg = "No Import File selected"; Utils.LogToFile(msg); resultLabel.Text = msg; } else { if (backgroundWorker1.IsBusy != true) { // Start the asynchronous operation. backgroundWorker1.RunWorkerAsync(); } } }