public static void Dispose()
        {
            lock (register_drop_sync)
            {
                if (initialized && !disposing)
                {
                    disposing = true;
                }
            }

            try
            {
                if (downloads != null)
                {
                    CancelAll();

                    int count = 0;

                    do
                    {
                        lock (downloads.SyncRoot)
                        {
                            count = downloads.Count;
                        }
                    }while (count != 0);
                }

                if (dispatcher != null)
                {
                    dispatcher.Dispose();
                    dispatcher = null;
                }

                download_queue = null;

                if (tsm != null)
                {
                    tsm.Dispose();
                    tsm = null;
                }
            }
            finally
            {
                lock (register_drop_sync)
                {
                    disposing = false;
                }
            }

            lock (register_drop_sync)
            {
                disposed    = false;
                initialized = false;
            }
        }
        internal Dispatcher(DownloadQueue downloadQueue, TransferStatusManager statusManager)
        {
            if (downloadQueue == null)
            {
                throw new ArgumentNullException("downloadQueue");
            }
            else if (statusManager == null)
            {
                throw new ArgumentNullException("statusManager");
            }

            Enabled = false;

            tsm            = statusManager;
            download_queue = downloadQueue;

            registered_downloads = new Hashtable();
        }
        internal Dispatcher(DownloadQueue downloadQueue, TransferStatusManager statusManager)
        {
            if (downloadQueue == null)
            {
                throw new ArgumentNullException ("downloadQueue");
            }
            else if (statusManager == null)
            {
                throw new ArgumentNullException ("statusManager");
            }

            Enabled = false;

            tsm = statusManager;
            download_queue = downloadQueue;

            registered_downloads = new Hashtable ();
        }
        public static void Initialize()
        {
            lock (register_drop_sync)
            {
                if (initializing || initialized)
                {
                    return;
                }

                initializing = true;
            }

            try
            {
                tsm = new TransferStatusManager();
                tsm.DownloadTaskFinished += OnDownloadTaskFinishedHandler;
                tsm.StatusUpdated        += OnStatusUpdatedHandler;

                download_queue = new DownloadQueue();
                dispatcher     = new Dispatcher(download_queue, tsm);
                downloads      = new Hashtable();

                dispatcher.Initialize();
            }
            finally
            {
                lock (register_drop_sync)
                {
                    initializing = false;
                }
            }

            lock (register_drop_sync)
            {
                initialized = true;
            }

            // Attach NetworkStateChange event handlers
        }
        public static void Initialize()
        {
            lock (register_drop_sync)
            {
                if (initializing || initialized)
                {
                    return;
                }

                initializing = true;
            }

            try
            {
                tsm = new TransferStatusManager ();
                tsm.DownloadTaskFinished += OnDownloadTaskFinishedHandler;
                tsm.StatusUpdated += OnStatusUpdatedHandler;

                download_queue = new DownloadQueue ();
                dispatcher = new Dispatcher (download_queue, tsm);
                downloads = new Hashtable ();

                dispatcher.Initialize ();
            }
            finally
            {
                lock (register_drop_sync)
                {
                    initializing = false;
                }
            }

            lock (register_drop_sync)
            {
                initialized = true;
            }

            // Attach NetworkStateChange event handlers
        }
        public static void Dispose()
        {
            lock (register_drop_sync)
            {
                if (initialized && !disposing)
                {
                    disposing = true;
                }
            }

            try
            {
                if (downloads != null)
                {
                    CancelAll ();

                    int count = 0;

                    do
                    {
                        lock (downloads.SyncRoot)
                        {
                            count = downloads.Count;
                        }
                    }
                    while (count != 0);
                }

                if (dispatcher != null)
                {
                    dispatcher.Dispose ();
                    dispatcher = null;
                }

                download_queue = null;

                if (tsm != null)
                {
                    tsm.Dispose ();
                    tsm = null;
                }
            }
            finally
            {
                lock (register_drop_sync)
                {
                    disposing = false;
                }
            }

            lock (register_drop_sync)
            {
                disposed = false;
                initialized = false;
            }
        }