コード例 #1
0
        protected void updateTools(PackageChange change, int index)
        {
            PackageUpdate update = new PackageUpdate {
                change = change, index = index
            };

            if (!pendingUpdates.Contains(update))
            {
                pendingUpdates.Add(update);
                Task task = Task.Delay(queuingDelay);
                taskCompletion[task.Id] = false;
                tasks.Add(task);
                task.ContinueWith(x =>
                {
                    taskCompletion[x.Id] = true;
                    if (tasks.TrueForAll(t => taskCompletion[t.Id]))
                    {
                        tasks.Clear();
                        taskCompletion.Clear();
                        foreach (var item in Tools)
                        {
                            item.handleUpdate(pendingUpdates.ToList());
                        }
                        pendingUpdates.Clear();
                        OnPropertyChanged(nameof(IsModified));
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }
コード例 #2
0
        protected void updateTools(PackageChange change, int index)
        {
            PackageUpdate update = new PackageUpdate {
                change = change, index = index
            };

            if (!pendingUpdates.Contains(update))
            {
                pendingUpdates.Add(update);
                Task task = Task.Delay(queuingDelay);
                taskCompletion[task.Id] = false;
                tasks.Add(task);
                task.ContinueWithOnUIThread(x =>
                {
                    taskCompletion[x.Id] = true;
                    if (tasks.TrueForAll(t => taskCompletion[t.Id]))
                    {
                        tasks.Clear();
                        taskCompletion.Clear();
                        var removedImports     = pendingUpdates.Where(u => u.change == PackageChange.ImportRemove).Select(u => u.index).ToList();
                        var removedExports     = pendingUpdates.Where(u => u.change == PackageChange.ExportRemove).Select(u => u.index).ToList();
                        var pendingUpdatesList = new List <PackageUpdate>();
                        foreach (PackageUpdate upd in pendingUpdates)
                        {
                            switch (upd.change)
                            {
                            case PackageChange.ExportAdd:
                            case PackageChange.ExportData:
                            case PackageChange.ExportHeader:
                                {
                                    if (!removedExports.Contains(upd.index))
                                    {
                                        pendingUpdatesList.Add(upd);
                                    }
                                    break;
                                }

                            case PackageChange.ImportAdd:
                            case PackageChange.Import:
                                {
                                    if (!removedImports.Contains(upd.index))
                                    {
                                        pendingUpdatesList.Add(upd);
                                    }
                                    break;
                                }

                            default:
                                pendingUpdatesList.Add(upd);
                                break;
                            }
                        }
                        pendingUpdates.Clear();
                        foreach (var item in Tools)
                        {
                            item.handleUpdate(pendingUpdatesList);
                        }
                        OnPropertyChanged(nameof(IsModified));
                    }
                });
            }
        }
コード例 #3
0
ファイル: MEPackage.cs プロジェクト: ME3Explorer/ME3Explorer
 protected void updateTools(PackageChange change, int index)
 {
     PackageUpdate update = new PackageUpdate { change = change, index = index };
     if (!pendingUpdates.Contains(update))
     {
         pendingUpdates.Add(update);
         Task task = Task.Delay(queuingDelay);
         taskCompletion[task.Id] = false;
         tasks.Add(task);
         task.ContinueWith(x =>
         {
             taskCompletion[x.Id] = true;
             if (tasks.TrueForAll(t => taskCompletion[t.Id]))
             {
                 tasks.Clear();
                 taskCompletion.Clear();
                 foreach (var item in Tools)
                 {
                     item.handleUpdate(pendingUpdates.ToList());
                 }
                 pendingUpdates.Clear();
                 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsModified)));
             }
         }, TaskScheduler.FromCurrentSynchronizationContext());
     }
 }