problem with file watcher and datagrid

  • Thread starter Thread starter R.A.
  • Start date Start date
R

R.A.

Hi

I have a class which contains a datagrid and a file watcher object.
When the file watcher event is triggered then in the event handler I add
rows to the data grid. the problem is that every time I add rows to the
datagrid from the file watcher event handler the program stops - there are
no exceptions thrown the program just terminates. I have checked the
datagrid without adding rows in the file watcher handler and there are no
issues. I need to get the file name from the file watcher handler so that I
will display the file name in the datagrid.
Any ideas what is happening?



Thanks
 
Did you set the SynchronizingObject of the FileSystemWatcher to the data
grid object (or maybe your form object)? I think if you do that then the
events will come back on your UI thread -- which is the only safe place to
muck with UI objects.

Brad Williams
 
Back
Top