/* Iterates over all application hooks creating a new thread for each
         * to run in. Hooks are run concurrently and this method waits for
         * them to finish.
         */
        internal static void RunHooks()
        {
            Collection <Thread> threads;

            lock (typeof(ApplicationShutdownHooks))
            {
                threads = Hooks.KeySet();
                Hooks   = null;
            }

            foreach (Thread hook in threads)
            {
                hook.Start();
            }
            foreach (Thread hook in threads)
            {
                try
                {
                    hook.Join();
                }
                catch (InterruptedException)
                {
                }
            }
        }