c# - EnableRaisingEvents (enabling and disabling it) -


I am maintaining some code containing two FileSystemWatcher events that make it difficult to debug (and there is an error in it). So my idea is to simplify the code by executing sequential execution. This is very beautiful:

  Main method 1) Normal code here 2) Enable event 1, check it for files, disable it when enabled to run 3 times once) Events 2, check it for two files, disable it when it is done to run once   

Then the database log will understand more than I can see some part of the program Will be capable of doing something wrong.

  Private Zero start initializeFileSystemWatcher () {this.MessageMonitor = New FileSystemWatcher (This. MessagePath, this.MessageFilter); This.MessageMonitor.IncludeSubdirectories = true; // Recurring This.MessageMonitor.Created + = New FileSystemEventHandler (OnMessageReceived); This.MessageMonitor.EnableRaisingEvents = True; }   

From the main, I can enable EnableRaisingEvents = true EnableRaisingEvents = false. Both events list files in some folders and inform callback method.

My question is: If the event is currently being executed and I set EnableRaisingEvents = false, then it will have to stop it?

If this continues, I understand a bool doRUN variable set at the end of the beginning and end as a check for the main method.

To make sure you are working properly and then the other FileSystemWatcher < / Code>.

Inside the message you may like something

  Receive the public zero on-message (object sender, event e) // not the actual signature {message monitor. Created - = on message recycled (); // Monitor Your Things Other Messages Ready + = On Message Received (); }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

c# - Confused over DLL entry points (entry point not found exception) -