Пример #1
0
 private static void ControllerOnPluginProgressUpdated(IPlugin plugin, ProgressProvider progressProvider)
 {
     var line = string.Format("{0} is {1} - {2} complete - {3} - {4} elapsed, {5} remaining",
                              plugin.Name, progressProvider.State, (progressProvider.PercentComplete / 100.0).ToString("P"),
                              progressProvider.Status,
                              progressProvider.RunTime.ToStringShort(),
                              progressProvider.TimeRemaining.ToStringShort());
     if (progressProvider.State == ProgressProviderState.Running)
     {
         Console.WriteLine("\r{0}", line);
     }
     else
     {
         Console.WriteLine(line);
     }
 }
Пример #2
0
        private void ControllerOnPluginProgressUpdated(IPlugin plugin, ProgressProvider progressProvider)
        {
            if (!_isRunning)
                return;

            _state = progressProvider.State;

            var percentCompleteStr = (progressProvider.PercentComplete/100.0).ToString("P");
            var line = string.Format("{0} is {1} - {2} complete - {3} - {4} elapsed, {5} remaining",
                                     plugin.Name, progressProvider.State, percentCompleteStr,
                                     progressProvider.Status,
                                     progressProvider.RunTime.ToStringShort(),
                                     progressProvider.TimeRemaining.ToStringShort());
            AppendStatus(line);

            progressBar.ValuePercent = progressProvider.PercentComplete;
            _progressBarToolTip.SetToolTip(progressBar, string.Format("{0}: {1}", progressProvider.State, percentCompleteStr));
            _taskbarItem.Progress = progressProvider.PercentComplete;

            switch (progressProvider.State)
            {
                case ProgressProviderState.Error:
                    progressBar.SetError();
                    _taskbarItem.Error();
                    break;
                case ProgressProviderState.Paused:
                    progressBar.SetPaused();
                    _taskbarItem.Pause();
                    break;
                case ProgressProviderState.Canceled:
                    progressBar.SetMuted();
                    _taskbarItem.NoProgress();
                    break;
                default:
                    progressBar.SetSuccess();
                    _taskbarItem.Normal();
                    break;
            }
        }
Пример #3
0
        private void ProgressProviderOnUpdated(ProgressProvider progressProvider)
        {
            if (PluginProgressUpdated != null)
            {
                // Marshal event back to UI thread
                Task.Factory.StartNew(delegate
                    {
                        var guid = progressProvider.Plugin.AssemblyInfo.Guid;
                        var hashCode = progressProvider.GetHashCode();

                        var containsKey = _progressMap.ContainsKey(guid);
                        var prevHashCode = containsKey ? _progressMap[guid] : -1;

                        Logger.DebugFormat(
                            "ProgressProviderOnUpdated() - Plugin \"{0}\": prev progress hashCode = {1}, cur progress hashCode = {2}",
                            progressProvider.Plugin.Name, prevHashCode, hashCode
                        );

                        // Progress hasn't changed since last update
                        if (containsKey && prevHashCode == hashCode)
                            return;

                        _progressMap[guid] = hashCode;

                        Logger.Debug("ProgressProviderOnUpdated() - Calling PluginProgressUpdated event handlers");

                        PluginProgressUpdated(progressProvider.Plugin, progressProvider);
                    }, CancellationToken.None, TaskCreationOptions.None, _callbackScheduler);
            }
        }