I'm writing a music player. This is the (early) code that adds a directory to the playlist:
private void SelectFolderButton_Click(object sender, EventArgs e)
{
int count = 0;
AddFolderDialog.ShowDialog();
if(AddFolderDialog.SelectedPath != string.Empty)
{
BackgroundWorker bgw = new BackgroundWorker();
bgw.DoWork += (a,b) => playlist.AddFolder(AddFolderDialog.SelectedPath, RecursiveCheckBox.Checked, out count);
bgw.RunWorkerAsync();
bgw.RunWorkerCompleted += (a, b) => mainStatusLabel.Text = "Added " + count + " songs"; ;
bgw.RunWorkerCompleted += (a, b) => DrawPlaylist();
}
}
I just started using threads. The first question is, is this a correct code? Is there something glaringly wrong here? The second issue is that I want to regularly display the number of added songs as they're being added. Not necessarily song-by-song; once a second is fine. How do I achieve this?