private static void EmitDownloadEvent(DownloadEventHandler handler, DownloadEventArgs args)
 {
     if (handler != null)
     {
         handler(null, args);
     }
 }
Exemple #2
0
        protected virtual void OnDownloadTaskFinishedHandler(object sender,
                                                             DownloadEventArgs args)
        {
            DownloadInfo dif = args.DownloadInfo;
            DownloadTask dt  = sender as DownloadTask;

            Finished(dif, dt);
            OnStatusUpdated();
        }
Exemple #3
0
        protected virtual void OnDownloadStateChanged(DownloadEventHandler handler,
                                                      DownloadEventArgs args)
        {
            DownloadEventHandler local_handler = handler;

            if (local_handler != null)
            {
                local_handler(this, args);
            }
        }
Exemple #4
0
        protected virtual void OnDownloadTaskStoppedHandler(object sender,
                                                            DownloadEventArgs args)
        {
            lock (syncRoot)
            {
                --CurrentDownloads;
            }

            //OnStatusUpdated ();
            OnDownloadStateChanged(DownloadTaskStopped, args);
        }
        private static void OnDownloadTaskFinishedHandler(object sender,
                                                          DownloadEventArgs args)
        {
            DownloadInfo dif = args.DownloadInfo;

            DownloadInfo[] difs = null;

            if (dif == null)
            {
                return;
            }

            bool drop_queued = false;

            lock (mass_drop_sync)
            {
                if (mass_drop_queue.Contains(dif))
                {
                    dropped.Add(dif);
                    drop_queued = true;
                }

                if (mass_drop_queue.Count > 0 &&
                    dropped.Count == mass_drop_queue.Count)
                {
                    difs = dropped.ToArray(typeof(DownloadInfo)) as DownloadInfo[];

                    dropped.Clear();
                    mass_drop_queue.Clear();
                }
            }

            if (difs != null)
            {
                ArrayList dropped_downloads = new ArrayList(difs.Length);

                foreach (DownloadInfo d in difs)
                {
                    try
                    {
                        Drop(d, false);
                        dropped_downloads.Add(d);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                if (dropped_downloads.Count == 1)
                {
                    EmitDownloadDropped(new DownloadEventArgs(
                                            dropped_downloads [0] as DownloadInfo)
                                        );
                }
                else if (dropped_downloads.Count > 1)
                {
                    EmitDownloadDropped(new DownloadEventArgs(dropped_downloads));
                }

                EmitDownloadDropped(new DownloadEventArgs(dropped_downloads));
            }
            else if (!drop_queued)
            {
                try
                {
                    Drop(dif, true);
                }
                catch {}
            }
        }
        private static void OnDownloadTaskFinishedHandler(object sender,
                DownloadEventArgs args)
        {
            DownloadInfo dif = args.DownloadInfo;
            DownloadInfo[] difs = null;

            if (dif == null)
            {
                return;
            }

            bool drop_queued = false;

            lock (mass_drop_sync)
            {
                if (mass_drop_queue.Contains (dif))
                {
                    dropped.Add (dif);
                    drop_queued = true;
                }

                if (mass_drop_queue.Count > 0 &&
                        dropped.Count == mass_drop_queue.Count)
                {
                    difs = dropped.ToArray (typeof (DownloadInfo)) as DownloadInfo[];

                    dropped.Clear ();
                    mass_drop_queue.Clear ();
                }
            }

            if (difs != null)
            {
                ArrayList dropped_downloads = new ArrayList (difs.Length);

                foreach (DownloadInfo d in difs)
                {
                    try
                    {
                        Drop (d, false);
                        dropped_downloads.Add (d);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                if (dropped_downloads.Count == 1)
                {
                    EmitDownloadDropped (new DownloadEventArgs (
                                             dropped_downloads [0] as DownloadInfo)
                                        );
                }
                else if (dropped_downloads.Count > 1)
                {
                    EmitDownloadDropped (new DownloadEventArgs (dropped_downloads));
                }

                EmitDownloadDropped (new DownloadEventArgs (dropped_downloads));
            }
            else if (!drop_queued)
            {
                try
                {
                    Drop (dif, true);
                }
                catch {}
            }
        }
        protected virtual void OnDownloadTaskFinishedHandler(object sender,
                DownloadEventArgs args)
        {
            DownloadInfo dif = args.DownloadInfo;
            DownloadTask dt = sender as DownloadTask;

            Finished (dif, dt);
            OnStatusUpdated ();
        }
 private static void EmitRegistrationFailed(DownloadEventArgs args)
 {
     EmitDownloadEvent(RegistrationFailed, args);
 }
 private static void EmitDownloadEvent(DownloadEventHandler handler, DownloadEventArgs args)
 {
     if (handler != null)
     {
         handler (null, args);
     }
 }
 private static void EmitDownloadDropped(DownloadEventArgs args)
 {
     EmitDownloadEvent (DownloadDropped, args);
 }
 private static void OnRegistrationFailedHandler(object sender,
         DownloadEventArgs args)
 {
     DownloadEventAction (args, DownloadRegistrationFailed);
 }
 private static void OnDownloadTaskStoppedHandler(object sender,
         DownloadEventArgs args)
 {
     DownloadInfo dif = args.DownloadInfo;
     DownloadTaskStartedOrStopped (dif, false);
 }
 private static void OnDownloadDroppedHandler(object sender,
         DownloadEventArgs args)
 {
     DownloadEventAction (args, DownloadDropped);
 }
        private static void DownloadEventAction(DownloadEventArgs args,
                DownloadAction action)
        {
            if (args.DownloadInfo != null)
            {
                lock (downloads.SyncRoot)
                {
                    action (args.DownloadInfo);
                }
            }
            else if (args.Downloads != null)
            {
                lock (downloads.SyncRoot)
                {
                    foreach (DownloadInfo dif in args.Downloads)
                    {
                        if (dif != null)
                        {
                            action (dif);
                        }
                    }
                }
            }

            source.Update ();
        }
        protected virtual void OnDownloadTaskStoppedHandler(object sender,
                DownloadEventArgs args)
        {
            lock (syncRoot)
            {
                --CurrentDownloads;
            }

            //OnStatusUpdated ();
            OnDownloadStateChanged (DownloadTaskStopped, args);
        }
 private static void EmitDownloadRegistered(DownloadEventArgs args)
 {
     EmitDownloadEvent(DownloadRegistered, args);
 }
 private static void EmitDownloadDropped(DownloadEventArgs args)
 {
     EmitDownloadEvent(DownloadDropped, args);
 }
 private static void EmitDownloadRegistered(DownloadEventArgs args)
 {
     EmitDownloadEvent (DownloadRegistered, args);
 }
 private static void EmitRegistrationFailed(DownloadEventArgs args)
 {
     EmitDownloadEvent (RegistrationFailed, args);
 }
        protected virtual void OnDownloadStateChanged(DownloadEventHandler handler,
                DownloadEventArgs args)
        {
            DownloadEventHandler local_handler = handler;

            if (local_handler != null)
            {
                local_handler (this, args);
            }
        }