protected void OnScriptChanged(string name) { if (ScriptChanged != null) { var script = this[name]; ScriptChanged.Invoke(this, new ScriptChangedEventArgs(name, script)); } }
private Task PublishChangeAsync(Script script) { var message = new ScriptChanged { Id = script.Id, Body = script.Body }; return(_messageBroker.PublishAsync(message)); }
private void cbScripts_SelectedValueChanged(object sender, EventArgs e) { ComboBox cb = (ComboBox)sender; if (cb.SelectedItem != null) { _CurrentScript = cb.SelectedItem.ToString(); ScriptChanged?.Invoke(this, _CurrentScript); txtResultsName.Text = $"Results_{_CurrentScript}_{DateTime.Now.ToString("yyyyMMddHHmmss")}"; } }
private void UpdateScript() { // Disable timer, to wait for execution of this iteration to // finish. This can be useful if blocking operations like // showing a message window are used. _update_timer.Enabled = false; // this is ugly, fix eventually! if (_settings.ScriptPath != _old_script_path || _do_reload) { try { _do_reload = false; _old_script_path = _settings.ScriptPath; ScriptCleanup(); if (string.IsNullOrEmpty(_settings.ScriptPath)) { // Only disable file watcher if script path changed to empty // (otherwise detecting file changes may still be wanted) _fs_watcher.EnableRaisingEvents = false; } else { LoadScript(); } ScriptChanged?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { Log.Error(ex); } } if (Script != null) { try { Script.Update(_state); } catch (Exception ex) { Log.Error(ex); } } _update_timer.Enabled = true; }
public override void Dispose() { ScriptCleanup(); try { ScriptChanged?.Invoke(this, EventArgs.Empty); } catch (Exception ex) { Log.Error(ex); } _fs_watcher?.Dispose(); _update_timer?.Dispose(); }