Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- private List<LogInfo> logs = new List<LogInfo>();
- private static Object lockObj = new Object();
- private static Object lockObj0 = new Object();
- /* ... */
- void fileSystemWatcher_Renamed(object sender, RenamedEventArgs e)
- {
- try
- {
- ToggleWatcher(false);
- LogInfo logInfo = new LogInfo(e.ChangeType, GetCurrentTime(), e.FullPath, e.OldName, e.Name);
- lock (lockObj)
- {
- logs.Add(logInfo);
- listBox1.Items.Add(logInfo.ToString());
- }
- }
- finally
- {
- ToggleWatcher(true);
- }
- }
- void fileSystemWatcher_Detect(object sender, FileSystemEventArgs e)
- {
- try
- {
- ToggleWatcher(false);
- LogInfo logInfo = new LogInfo(e.ChangeType, GetCurrentTime(), e.FullPath);
- lock (lockObj)
- {
- logs.Add(logInfo);
- // Here in below line i get error: invalidoperationexception was unhandled
- listBox1.Items.Add(logInfo.ToString());
- }
- }
- finally
- {
- ToggleWatcher(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement