Пример #1
0
        /// <summary>
        /// Unloads a module with the specified id.
        /// </summary>
        /// <param name='id'>
        /// The identifier of the module to unload.
        /// </param>
        public virtual void Unload(Guid id)
        {
            lock (ScannerList)
            {
                try
                {
                    Debugger.Status("Attempt to remove module: " + id.ToString());

                    //Remove the scanner items and invoke garbage collection.
                    if (ScannerList.ContainsKey(id))
                    {
                        ScannerList.Remove(id);
                        ScheduledList.Remove(id);
                    }
                    else if (HandlerList.ContainsKey(id))
                    {
                        HandlerList.Remove(id);
                    }
                    else
                    {
                        throw new Exception("Module not found.");
                    }

                    GC.Collect();
                    Debugger.Success();
                }
                catch (Exception e)
                {
                    Debugger.Failure(e);
                }
            }
        }