You will need to call Application.Run () in your Main () method to get the Windows Forms in sync in place so that FileSystemWatcher can properly march the call to the main thread. The problem that you will have is that the main form will become visible. Fix this by inserting this code into the class:
protected override void SetVisibleCore(bool value) {
if (!this.IsHandleCreated) {
this.CreateHandle();
value = false;
}
base.SetVisibleCore(value);
}
There is no limit to what your form looks like if you do.
source
share