Simply put...
private void LoadImage(object sender, EventArgs e){
String path = null;
Microsoft.Win32.OpenFileDialog oFD = new ...();
if(oFD.showDialog == true){
path = oFD.FileName;
result = new BitmapImage(new Uri(path));
Array.Resize(ref frames, frames.Length + 1);
frames.Append<BitmapSource>(result);
}
Refresh();
}
private void Refresh(){
BitmapSource bg = frames[curFrame]; //i.e. curFrame = 0;
}
I expected bg to not be null when Refresh() is called. I caught all relevant exceptions except for bg being null, in which I don't want bg to be null when the program is executing.