In my code, I am using a backgroundworker to do a task and I set that task's return value as the DoWorkEventArgs Result. The strange thing is is that during the DoWork event, the Result is set and contains items, but when I access the result in the RunWorkerCompleted event, SOMETIMES the Result is empty!
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
var i = YouTubeDownloader.GetYouTubeVideoUrls(videoUrls);
e.Result = i; //Contains items
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
UseWaitCursor = false;
if (e.Error != null)
throw e.Error;
List<YouTubeVideoQuality> urls = e.Result as List<YouTubeVideoQuality>; // Empty?