Anonymous - 2012-07-13

Hello,

I am trying to use the ShellTreeView control to create a custom explorer-like file browser.  Essentially I am only looking at the "SelectionChanged" event and then using the current value of "myControl.SelectedFolder.FileSystemPath" to go and run a custom routine where I pull files of my specified format and draw preview thumbnails using basic GDI functionality.

This all works great except that I am frequently seeing this following exception pop up:

An Application Error has occurred.
EXCEPTION:
System.InvalidOperatoinException: Cross-thread operation not valid:  Control "accessed from a thread other than the thread it was created on.
  at System.Windows.Forms.Control.get_Handle()
  at System.Windows.Forms.Control.get_InternalHandle()
  at System.Windows.Forms.Control.DestroyHandle()
  at System.Windows.Forms.Control.Dispose(Boolean disposing)
  at GongSolutions.Shell.ShellNotificationListener.NotificationWindow.Dispose(Boolean disposing)
  at System.ComponentModel.Component.Dispose()
  at GongSolutions.Shell.ShellNotificationListener.Dispose(Boolean disposing)
  at System.ComponentModel.Component.Finalize()

As you can see this seems to have something to do with the control being diposed of.  The error often occurs after the user has selected the file they want and closed the dialog containing this control.

Any help with this would be much appreciated.

Thanks,

-DC