Notifies the object that initialization is beginning and tells it to standby.
[Visual Basic] Overridable Public Sub BeginInit() [C#] public virtual void BeginInit(); [C++] public: virtual void BeginInit(); [JScript] public function BeginInit();
Use this method when you need to change multiple properties on the component all at once. By calling BeginInit, you suspend the component from watching and prevent it from checking its state. Watching the directory and checking its state is resumed by the component when EndInit is called.
Using BeginInit helps keep resource use low. If you do not call BeginInit and EndInit to change multiple properties, then every change you make will cause the component to unhook itself from the system and then reattach itself.
Note The component is not checking its state after BeginInit, and before EndInit, is called. If Enabled is true, you must supply a valid path for the Path property. The component will not begin watching until a valid path is set.
FileSystemWatcher Class | FileSystemWatcher Members | System.IO Namespace | EndInit