示例#1
0
 internal void Cancel()
 {
     this.IsActive = false;
     lock (this.initializeTypeSyncLock)
     {
         if (this.initializeTypeProcess != null)
         {
             this.initializeTypeProcess.Complete -= new EventHandler(this.InitializeTypeProcess_Complete);
             this.initializeTypeProcess.Kill();
             this.initializeTypeProcess = (AsyncQueueProcess)null;
             lock (this.typeDictionaryLock)
                 this.typeDictionary = (Dictionary <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]>)null;
         }
     }
     lock (this.initializeListSyncLock)
     {
         if (this.initializeListProcess == null)
         {
             return;
         }
         this.initializeListProcess.Complete -= new EventHandler(this.OnInitializeListProcessComplete);
         this.initializeListProcess.Kill();
         this.initializeListProcess = (AsyncQueueProcess)null;
         lock (this.properties)
         {
             this.IsDirty = true;
             this.properties.Clear();
         }
     }
 }
示例#2
0
            internal void BeginScanAssembliesAsync(IEnumerable <TypeChangedInfo> assemblyInfosToScan)
            {
                lock (this.initializeTypeSyncLock)
                {
                    if (this.initializeTypeProcess == null)
                    {
                        this.initializeTypeProcess           = new AsyncQueueProcess((IAsyncMechanism) new BackgroundWorkerAsyncMechanism(BackgroundWorkMode.ThreadHog));
                        this.initializeTypeProcess.Complete += new EventHandler(this.InitializeTypeProcess_Complete);
                    }
                }
                List <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly> list = new List <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly>();

                foreach (TypeChangedInfo typeChangedInfo in assemblyInfosToScan)
                {
                    if (this.ShouldScanAssembly(typeChangedInfo.Assembly.Name))
                    {
                        int hi;
                        int lo;
                        if (AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.FindArrayBounds(this.properties, typeChangedInfo.Assembly.Name, (string)null, (string)null, out hi, out lo))
                        {
                            this.IsDirty = true;
                            this.properties.RemoveRange(lo, hi - lo + 1);
                        }
                        if (typeChangedInfo.ModificationAction != ModificationType.Removed && typeChangedInfo.Assembly.IsLoaded)
                        {
                            list.Add(new AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly(AssemblyHelper.GetReflectionAssembly(typeChangedInfo.Assembly), this.runtimeContext, this.referenceContext));
                        }
                        this.scannedAssemblies.Add(typeChangedInfo.Assembly.Name);
                    }
                }
                lock (this.initializeTypeSyncLock)
                {
                    lock (this.typeDictionaryLock)
                        this.typeDictionary = new Dictionary <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]>();
                    if (this.initializeTypeProcess == null)
                    {
                        return;
                    }
                    this.IsActive = true;
                    this.initializeTypeProcess.Add((AsyncProcess) new EnumeratingAsyncProcess <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly>((IAsyncMechanism)null, (IEnumerable <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly>)list, (Action <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly>)(assemblyTuple =>
                    {
                        try
                        {
                            if (assemblyTuple == null)
                            {
                                return;
                            }
                            lock (this.typeDictionaryLock)
                                this.typeDictionary.Add(assemblyTuple, assemblyTuple.GetReflectionTypes());
                        }
                        catch (ReflectionTypeLoadException ex)
                        {
                        }
                        catch (ArgumentException ex)
                        {
                        }
                    })), true);
                }
            }
示例#3
0
            private void InitializeTypeProcess_Complete(object sender, EventArgs e)
            {
                Dictionary <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]> dictionary = new Dictionary <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]>();

                lock (this.typeDictionaryLock)
                {
                    foreach (KeyValuePair <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]> item_0 in this.typeDictionary)
                    {
                        dictionary.Add(item_0.Key, item_0.Value);
                    }
                }
                lock (this.initializeListSyncLock)
                {
                    if (dictionary.Count != 0)
                    {
                        if (this.initializeListProcess == null)
                        {
                            this.initializeListProcess           = new AsyncQueueProcess((IAsyncMechanism) new BackgroundWorkerAsyncMechanism(BackgroundWorkMode.ThreadHog));
                            this.initializeListProcess.Complete += new EventHandler(this.OnInitializeListProcessComplete);
                        }
                        foreach (KeyValuePair <AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly, Type[]> item_1 in dictionary)
                        {
                            AttachedPropertiesMetadata.AttachedPropertyMetadataBackgroundWorker.AttachedPropertyReferenceAssembly assemblies = item_1.Key;
                            this.initializeListProcess.Add((AsyncProcess) new EnumeratingAsyncProcess <Type>((IAsyncMechanism)null, (IEnumerable <Type>)item_1.Value, (Action <Type>)(type =>
                            {
                                lock (this.properties)
                                {
                                    if (this.initializeListProcess == null || !this.initializeListProcess.IsAlive)
                                    {
                                        return;
                                    }
                                    this.UpdateAttachedProperties(type, assemblies);
                                }
                            })), true);
                        }
                    }
                    else
                    {
                        this.IsActive = false;
                    }
                }
            }
 public AsyncExecutionHelper()
 {
     this.processingQueue = new AsyncQueueProcess((IAsyncMechanism) new DispatcherTimerAsyncMechanism(DispatcherPriority.Background, new TimeSpan(0, 0, 0, 0, 10)));
 }