protected override void Dispose(bool disposing) { if (disposing) { _isDisposing = true; if (_watcher != null) { // Disable startup of new reload-timers _watcher.FileChanged -= ConfigFileChanged; _watcher.StopWatching(); } var currentTimer = _reloadTimer; if (currentTimer != null) { _reloadTimer = null; currentTimer.WaitForDispose(TimeSpan.Zero); } // Dispose file-watcher after having dispose timer to avoid race _watcher?.Dispose(); } base.Dispose(disposing); }
public void Dispose() { CheckCloseAppenders = null; #if !SILVERLIGHT && !__IOS__ && !__ANDROID__ externalFileArchivingWatcher.Dispose(); logFileWasArchived = false; #endif var currentTimer = autoClosingTimer; if (currentTimer != null) { autoClosingTimer = null; currentTimer.WaitForDispose(TimeSpan.Zero); } }
/// <summary> /// Should only be called by Project.QueueEffectUpdate(Effect). /// Doesn't run on the main thread. /// </summary> public override void Update() { if (!scriptContainer.HasScript) { return; } var newDependencyWatcher = new MultiFileWatcher(); newDependencyWatcher.OnFileChanged += (sender, e) => { if (IsDisposed) { return; } Refresh(); }; var context = new EditorGeneratorContext(this, Project.ProjectFolderPath, Project.MapsetPath, Project.MainBeatmap, Project.MapsetManager.Beatmaps, newDependencyWatcher); var success = false; try { changeStatus(EffectStatus.Loading); var script = scriptContainer.CreateScript(); changeStatus(EffectStatus.Configuring); Program.RunMainThread(() => { beatmapDependant = true; if (script.Identifier != configScriptIdentifier) { script.UpdateConfiguration(Config); configScriptIdentifier = script.Identifier; RaiseConfigFieldsChanged(); } else { script.ApplyConfiguration(Config); } }); changeStatus(EffectStatus.Updating); script.Generate(context); foreach (var layer in context.EditorLayers) { layer.PostProcess(); } success = true; } catch (RemotingException e) { Debug.Print($"Script execution failed with RemotingException, reloading {BaseName} ({e.Message})"); changeStatus(EffectStatus.ReloadPending); Program.Schedule(() => { if (Project.IsDisposed) { return; } scriptContainer.ReloadScript(); }); return; } catch (ScriptCompilationException e) { Debug.Print($"Script compilation failed for {BaseName}\n{e.Message}"); changeStatus(EffectStatus.CompilationFailed, e.Message, context.Log); return; } catch (ScriptLoadingException e) { Debug.Print($"Script load failed for {BaseName}\n{e.ToString()}"); changeStatus(EffectStatus.LoadingFailed, e.InnerException != null ? $"{e.Message}: {e.InnerException.Message}" : e.Message, context.Log); return; } catch (Exception e) { changeStatus(EffectStatus.ExecutionFailed, getExecutionFailedMessage(e), context.Log); return; } finally { if (!success) { if (dependencyWatcher != null) { dependencyWatcher.Watch(newDependencyWatcher.WatchedFilenames); newDependencyWatcher.Dispose(); newDependencyWatcher = null; } else { dependencyWatcher = newDependencyWatcher; } } context.DisposeResources(); } changeStatus(EffectStatus.Ready, null, context.Log); Program.Schedule(() => { if (IsDisposed) { newDependencyWatcher.Dispose(); return; } beatmapDependant = context.BeatmapDependent; dependencyWatcher?.Dispose(); dependencyWatcher = newDependencyWatcher; if (Project.IsDisposed) { return; } if (placeHolderLayer != null) { Project.LayerManager.Replace(placeHolderLayer, context.EditorLayers); placeHolderLayer = null; } else { Project.LayerManager.Replace(layers, context.EditorLayers); } layers = context.EditorLayers; refreshLayerNames(); refreshEstimatedSize(); }); }
public void Dispose() { #if !SILVERLIGHT && !__IOS__ && !__ANDROID__ externalFileArchivingWatcher.Dispose(); #endif }