/// <summary> /// Progress of the plugin changed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void PluginProgressChanged(IPlugin sender, PluginProgressEventArgs args) { //Calculate % of the plugins process this.PercentageFinished = args.Value / args.Max; //Tell the ExecutionEngine that this plugin needs a gui update this.GuiNeedsUpdate = true; }
/// <summary> /// Called, when progress on a single plugin changed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnPluginProgressChanged(IPlugin sender, PluginProgressEventArgs args) { if (_terminationType == TerminationType.GlobalProgress) { HandleGlobalProgress(sender, args); } if (_terminationType == TerminationType.PluginProgress) { } }
private void ExecutionEngine_OnPluginProgressChanged(IPlugin sender, PluginProgressEventArgs args) { if (Cryptool.PluginBase.Properties.Settings.Default.WorkspaceManager_UseGlobalProgressbar) { if (DateTime.Now >= progressTime.AddSeconds(1)) { progressTime = DateTime.Now; this.WorkspaceSpaceEditorView.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback) delegate { WorkspaceSpaceEditorView.Progress = args.Value; }, null); } } }
/// <summary> /// Handles the global progress /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void HandleGlobalProgress(IPlugin sender, PluginProgressEventArgs args) { lock (_progressLockObject) { if (!_pluginProgressValues.ContainsKey(sender)) { _pluginProgressValues.Add(sender, args.Value / args.Max); } else { _pluginProgressValues[sender] = args.Value / args.Max; } double numberOfPlugins = _workspaceModel.GetAllPluginModels().Count; double totalProgress = 0; foreach (var value in _pluginProgressValues.Values) { totalProgress += value; } if (totalProgress == numberOfPlugins && _engine.IsRunning()) { if (_verbose) { Console.WriteLine("Global progress reached 100%, stop execution engine now"); } _engine.Stop(); } int newProgress = (int)((totalProgress / numberOfPlugins) * 100); if (_globalProgress < newProgress) { _globalProgress = newProgress; if (_verbose) { Console.WriteLine("Global progress change: {0}%", _globalProgress); } if (_jsonoutput) { Console.WriteLine(JsonHelper.GetProgressJson(_globalProgress)); } } } }
public static void ProgressChanged(PluginProgressChangedEventHandler del, IPlugin plugin, PluginProgressEventArgs args) { if (del == null) { return; } Delegate[] delegates = del.GetInvocationList(); if (AsynchronousProgressChanged) { AsyncCallback cleanUp = delegate(IAsyncResult asyncResult) { asyncResult.AsyncWaitHandle.Close(); }; foreach (PluginProgressChangedEventHandler sink in delegates) { sink.BeginInvoke(plugin, args, cleanUp, null); } } else { foreach (PluginProgressChangedEventHandler sink in delegates) { sink.Invoke(plugin, args); } } }