I have a FileSystemWatcher set to pick up an picture that will be dropped in a particular directory. The way I was handling it was to add a PictureBox in code that is docked inside of a panel. I ran it, it blew up, and I realized that I was not handling the interaction with the controls on the main thread correctly. Here is the code:
PictureBox pb = new PictureBox();
pnlCapturePicture.Controls.Add(pb);
pb.Dock = DockStyle.Fill;
pb.ImageLocation = photopath;
Now I understand how to make [Thread-Safe Calls to Windows Forms Controls][1] but I am curious if I just make the Panel Add thread safe am I really accomplishing anything?
Say if I did this:
PictureBox pb = new PictureBox();
AddControlThreadSafe(pb);
pb.Dock = DockStyle.Fill;
pb.ImageLocation = photopath;
Is interacting with the PictureBox control after it is added to the panel really thread safe?