protected sealed override HistoryMemento OnCommitChanges(TChanges changes)
        {
            string commitChangesHistoryMementoName = this.GetCommitChangesHistoryMementoName(changes);

            if (this.isCreatingSelection && (changes != this.createSelectionChanges))
            {
                this.InvalidateSelection();
            }
            DateTime utcNow = DateTime.UtcNow;
            TimeSpan span   = TimeSpan.FromSeconds(1.0);
            bool     flag   = false;

            do
            {
                if (this.PollForSelection(1))
                {
                    flag = true;
                    break;
                }
            }while ((DateTime.UtcNow - utcNow) < span);
            if (!flag)
            {
                VirtualTask <Unit> selectionTask = base.DocumentWorkspace.TaskManager.CreateVirtualTask(TaskState.Running);
                selectionTask.Progress = null;
                using (TaskProgressDialog dialog = new TaskProgressDialog())
                {
                    dialog.Task             = selectionTask;
                    dialog.CloseOnFinished  = true;
                    dialog.ShowCancelButton = false;
                    dialog.Text             = base.Name;
                    dialog.Icon             = base.Image.Reference.ToIcon();
                    dialog.HeaderText       = PdnResources.GetString("SaveConfigDialog.Finishing.Text");
                    using (System.Windows.Forms.Timer pollTimer = new System.Windows.Forms.Timer())
                    {
示例#2
0
 public void AddTask(VirtualTask t)
 {
     if (!HasTask(t.Name))
     {
         Tasks.Add(t.Name);
         if (Overhead >= (0.05 * t.WCET))
         {
             Overhead = (int)(0.05 * t.WCET);
         }
     }
 }
示例#3
0
        internal static Task <Unit> CreateFrameworkTasksWrapper(this TaskManager taskManager, IReadOnlyList <TupleStruct <Task, double> > fxTasksAndProgressWeights)
        {
            Validate.IsNotNull <IReadOnlyList <TupleStruct <Task, double> > >(fxTasksAndProgressWeights, "fxTasksAndProgressWeights");
            object             sync                = new object();
            int                count               = fxTasksAndProgressWeights.Count;
            int                completedCount      = 0;
            double             num                 = ((IEnumerable <double>)(from tapw in fxTasksAndProgressWeights select tapw.Item2)).Sum();
            double             totalProgressWeight = (num <= 0.0) ? 1.0 : num;
            VirtualTask <Unit> virtualTask         = taskManager.CreateVirtualTask(TaskState.Running);
            Action <int, Task> continueWithAction  = delegate(int index, Task task) {
                object obj1 = sync;
                lock (obj1)
                {
                    TupleStruct <Task, double> struct2 = fxTasksAndProgressWeights[index];
                    double increment = struct2.Item2 / totalProgressWeight;
                    virtualTask.IncrementProgressBy(increment);
                    completedCount += 1;
                    if (completedCount == count)
                    {
                        List <Exception> innerExceptions = null;
                        for (int k = 0; k < count; k++)
                        {
                            struct2 = fxTasksAndProgressWeights[k];
                            AggregateException exception = struct2.Item1.Exception;
                            if (exception != null)
                            {
                                innerExceptions = innerExceptions ?? new List <Exception>();
                                innerExceptions.AddRange(exception.InnerExceptions);
                            }
                        }
                        if (innerExceptions == null)
                        {
                            virtualTask.TaskResult = Result.Unit;
                        }
                        else
                        {
                            virtualTask.TaskResult = Result.NewError((innerExceptions.Count == 1) ? innerExceptions[0] : new AggregateException(innerExceptions), false);
                        }
                        virtualTask.SetState(TaskState.Finished);
                    }
                }
            };

            for (int j = 0; j < count; j++)
            {
                int index = j;
                TupleStruct <Task, double> struct2 = fxTasksAndProgressWeights[j];
                struct2.Item1.ContinueWith(delegate(Task t) {
                    continueWithAction(index, t);
                });
            }
            return(virtualTask);
        }
示例#4
0
        public void StartTask(Job job, int cycle)
        {
            VirtualTask task = Tasks.FirstOrDefault(x => x.Id == job.Id);

            if (task != null)
            {
                if (!task._started)
                {
                    task.executionTrace.Add(new Events(cycle, -1, task.Id.ToString(), task.CIL));
                    task._started = true;
                }
            }
        }
示例#5
0
            public VirtualTask(VirtualTask job)
            {
                Id             = job.Id;
                Name           = job.Name;
                _started       = job._started;
                CIL            = job.CIL;
                executionTrace = new List <Events>();
                foreach (var trace in job.executionTrace)
                {
                    executionTrace.Add(new Events(trace));
                }

                WCET = job.WCET;
            }
示例#6
0
            public VirtualTask(VirtualTask job)
            {
                _started    = false;
                Name        = job.Name;
                StartAccess = new List <int>();
                foreach (var s in job.StartAccess)
                {
                    SetStart(s);
                }

                foreach (var e in job.EndAccess)
                {
                    SetEnd(e);
                }

                EndAccess = new List <int>();
            }
示例#7
0
        public void EndTask(Job job, int cycle)
        {
            VirtualTask task = Tasks.FirstOrDefault(x => x.Id == job.Id);

            if (task != null)
            {
                if (task._started)
                {
                    task.executionTrace.Last().End = cycle;
                    task._started = false;
                }
                else
                {
                    task.executionTrace.RemoveAt(task.executionTrace.Count - 1);
                    task._started = false;
                }
            }
        }
示例#8
0
 private void UIWaitForCallbackDoneEvent(WaitActionType wat)
 {
     if (!this.callbackDoneEvent.WaitOne(0, false))
     {
         using (TaskManager manager = new TaskManager())
         {
             VirtualTask <Unit> cancelTask = manager.CreateVirtualTask(TaskState.Running);
             TaskProgressDialog dialog     = new TaskProgressDialog {
                 Task             = cancelTask,
                 CloseOnFinished  = true,
                 ShowCancelButton = false,
                 Icon             = base.Icon,
                 Text             = this.Text
             };
             if (wat != WaitActionType.Ok)
             {
                 if (wat != WaitActionType.Cancel)
                 {
                     throw ExceptionUtil.InvalidEnumArgumentException <WaitActionType>(wat, "wat");
                 }
                 dialog.HeaderText = PdnResources.GetString("TaskProgressDialog.Canceling.Text");
             }
             else
             {
                 dialog.HeaderText = PdnResources.GetString("SaveConfigDialog.Finishing.Text");
             }
             dialog.Shown += (< sender >, <e>) => Work.QueueWorkItem(delegate {
                 try
                 {
                     this.callbackDoneEvent.WaitOne();
                 }
                 finally
                 {
                     cancelTask.SetState(TaskState.Finished);
                 }
             });
             dialog.ShowDialog(this);
         }
     }
 }
示例#9
0
 protected override void OnComboBoxGotFocus(object sender, EventArgs e)
 {
     if (!this.isPopulated)
     {
         this.isPopulated = true;
         using (new WaitCursorChanger(base.ComboBox))
         {
             string selectedItem = (string)base.ComboBox.SelectedItem;
             string str2         = null;
             ManualResetEventSlim gotFamilies = new ManualResetEventSlim(false);
             string[]             fontNames   = null;
             VirtualTask <Unit>   task        = TaskManager.Global.CreateVirtualTask(TaskState.Running);
             IFontMap             fontMapP    = this.fontMap.CreateRef();
             Work.QueueWorkItem(delegate {
                 try
                 {
                     fontNames = fontMapP.ToArrayEx <string>();
                 }
                 finally
                 {
                     fontMapP.Dispose();
                     try
                     {
                         gotFamilies.Set();
                     }
                     finally
                     {
                         task.SetState(TaskState.Finished);
                     }
                 }
             });
             if (!gotFamilies.Wait(0x3e8))
             {
                 new TaskProgressDialog {
                     Task             = task,
                     CloseOnFinished  = true,
                     ShowCancelButton = false,
                     Text             = PdnInfo.BareProductName,
                     Icon             = PdnInfo.AppIcon,
                     Text             = PdnResources.GetString("TextConfigWidget.LoadingFontsList.Text")
                 }.ShowDialog(base.ComboBox);
             }
             gotFamilies.Wait();
             base.ComboBox.BeginUpdate();
             base.ComboBox.Items.Clear();
             foreach (string str3 in fontNames)
             {
                 int num2 = base.ComboBox.Items.Add(str3);
                 if ((selectedItem != null) && DirectWriteFactory.FontNameComparer.Equals(selectedItem, str3))
                 {
                     str2 = str3;
                 }
             }
             if (str2 != null)
             {
                 base.ComboBox.SelectedItem = str2;
             }
             else
             {
                 base.ComboBox.SelectedItem = this.defaultFontName;
             }
             base.ComboBox.EndUpdate();
         }
     }
     base.OnComboBoxGotFocus(sender, e);
 }