I am having trouble hiding the form when the BackgroundWorker process is complete.
private void submitButton_Click(object sender, EventArgs e) { processing f2 = new processing(); f2.MdiParent = this.ParentForm; f2.StartPosition = FormStartPosition.CenterScreen; f2.Show(); this.Hide(); backgroundWorker1.RunWorkerAsync(); } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { // loop through and upload our sound bits string[] files = System.IO.Directory.GetFiles(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\wav", "*.wav", System.IO.SearchOption.AllDirectories); foreach (string soundBit in files) { System.Net.WebClient Client = new System.Net.WebClient(); Client.Headers.Add("Content-Type", "audio/mpeg"); byte[] result = Client.UploadFile("http://mywebsite.com/upload.php", "POST", soundBit); } } private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { formSubmitted f3 = new formSubmitted(); f3.MdiParent = this.ParentForm; f3.StartPosition = FormStartPosition.CenterScreen; f3.Show(); this.Hide(); }
Basically, after clicking the "Submit" button, the application starts uploading files to the web server via php script. After the download is complete, the RunWorkerCompleted method is launched, which opens the formSubmitted
form. The problem I am facing is that the processing
form does not close after the background worker completes, and the formSubmitted
opens directly on top of the processing
form - unlike what I want, having the processing
form then open the formSubmitted
form.
source share