Example #1
0
 internal void Add_DbgThread(DbgAppDomainImpl appDomain)
 {
     Dispatcher.VerifyAccess();
     lock (lockObj)
         appDomains.Add(appDomain);
     AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(appDomain, added: true));
 }
Example #2
0
 protected override void CloseCore(DbgDispatcher dispatcher)
 {
     DbgThread[]    removedThreads;
     DbgModule[]    removedModules;
     DbgAppDomain[] removedAppDomains;
     DbgObject[]    objsToClose;
     lock (lockObj) {
         removedThreads    = threads.ToArray();
         removedModules    = modules.ToArray();
         removedAppDomains = appDomains.ToArray();
         objsToClose       = closeOnContinueList.ToArray();
         threads.Clear();
         modules.Clear();
         appDomains.Clear();
         closeOnContinueList.Clear();
     }
     currentThread = default;
     if (removedThreads.Length != 0)
     {
         ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(removedThreads, added: false));
     }
     if (removedModules.Length != 0)
     {
         ModulesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgModule>(removedModules, added: false));
     }
     if (removedAppDomains.Length != 0)
     {
         AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(removedAppDomains, added: false));
     }
     foreach (var obj in objsToClose)
     {
         obj.Close(dispatcher);
     }
     foreach (var thread in removedThreads)
     {
         thread.Close(dispatcher);
     }
     foreach (var module in removedModules)
     {
         module.Close(dispatcher);
     }
     foreach (var appDomain in removedAppDomains)
     {
         appDomain.Close(dispatcher);
     }
     InternalRuntime.Close(dispatcher);
 }
Example #3
0
        internal void Remove_DbgThread(DbgAppDomainImpl appDomain, DbgEngineMessageFlags messageFlags)
        {
            Dispatcher.VerifyAccess();
            List <DbgThread>?threadsToRemove = null;
            List <DbgModule>?modulesToRemove = null;

            lock (lockObj) {
                bool b = appDomains.Remove(appDomain);
                if (!b)
                {
                    return;
                }
                for (int i = threads.Count - 1; i >= 0; i--)
                {
                    var thread = threads[i];
                    if (thread.AppDomain == appDomain)
                    {
                        if (threadsToRemove is null)
                        {
                            threadsToRemove = new List <DbgThread>();
                        }
                        threadsToRemove.Add(thread);
                        threads.RemoveAt(i);
                    }
                }
                for (int i = modules.Count - 1; i >= 0; i--)
                {
                    var module = modules[i];
                    if (module.AppDomain == appDomain)
                    {
                        if (modulesToRemove is null)
                        {
                            modulesToRemove = new List <DbgModule>();
                        }
                        modulesToRemove.Add(module);
                        modules.RemoveAt(i);
                    }
                }
            }
            if (threadsToRemove is not null && threadsToRemove.Count != 0)
            {
                ThreadsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgThread>(threadsToRemove, added: false));
            }
            if (modulesToRemove is not null && modulesToRemove.Count != 0)
            {
                ModulesChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgModule>(modulesToRemove, added: false));
            }
            owner.RemoveAppDomain_DbgThread(this, appDomain, messageFlags);
            AppDomainsChanged?.Invoke(this, new DbgCollectionChangedEventArgs <DbgAppDomain>(appDomain, added: false));
            if (threadsToRemove is not null)
            {
                foreach (var thread in threadsToRemove)
                {
                    thread.Close(Dispatcher);
                }
            }
            if (modulesToRemove is not null)
            {
                foreach (var module in modulesToRemove)
                {
                    module.Close(Dispatcher);
                }
            }
            appDomain.Close(Dispatcher);
        }