Exemplo n.º 1
0
        private void OnChanged(object source, FileSystemEventArgs e)
        {
            if (Utils.GetUnixTimestamp(DateTime.Now) - lastMillis > 1000)
            {
                lastMillis = Utils.GetUnixTimestamp(DateTime.Now);
            }
            else
            {
                return;
            }

            try
            {
                watcher.EnableRaisingEvents = false;
                if (e.ChangeType == WatcherChangeTypes.Changed)
                {
                    var ph = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(e.FullPath)));
                    Mod.UnCookMod();
                    Task.Factory.StartNew(() =>
                    {
                        MainWindow.Instance.Runner.KillAllWorkers();
                        Mod.CompileScripts(MainWindow.Instance.Runner, true);
                    });
                }
            }
            finally
            {
                watcher.EnableRaisingEvents = true;
            }
        }