System.IO.KeventWatcher.GetInstance C# (CSharp) Méthode

GetInstance() public static méthode

public static GetInstance ( IFileWatcher &watcher ) : bool
watcher IFileWatcher
Résultat bool
		public static bool GetInstance (out IFileWatcher watcher)
		{
			if (failed == true) {
				watcher = null;
				return false;
			}

			if (instance != null) {
				watcher = instance;
				return true;
			}

			watches = Hashtable.Synchronized (new Hashtable ());
			var conn = kqueue();
			if (conn == -1) {
				failed = true;
				watcher = null;
				return false;
			}
			close (conn);

			instance = new KeventWatcher ();
			watcher = instance;
			return true;
		}

Usage Example

        void InitWatcher()
        {
            lock (lockobj)
            {
                if (watcher != null)
                {
                    return;
                }

                string managed = Environment.GetEnvironmentVariable("MONO_MANAGED_WATCHER");
                int    mode    = 0;
                if (managed == null)
                {
                    mode = InternalSupportsFSW();
                }

                bool ok = false;
                switch (mode)
                {
                case 1: // windows
                    ok = DefaultWatcher.GetInstance(out watcher);
                    //ok = WindowsWatcher.GetInstance (out watcher);
                    break;

                case 2: // libfam
                    ok = FAMWatcher.GetInstance(out watcher, false);
                    break;

                case 3: // kevent
                    ok = KeventWatcher.GetInstance(out watcher);
                    break;

                case 4: // libgamin
                    ok = FAMWatcher.GetInstance(out watcher, true);
                    break;

                case 5: // inotify
                    ok = InotifyWatcher.GetInstance(out watcher, true);
                    break;
                }

                if (mode == 0 || !ok)
                {
                    if (String.Compare(managed, "disabled", true) == 0)
                    {
                        NullFileWatcher.GetInstance(out watcher);
                    }
                    else
                    {
                        DefaultWatcher.GetInstance(out watcher);
                    }
                }

                ShowWatcherInfo();
            }
        }
All Usage Examples Of System.IO.KeventWatcher::GetInstance