コード例 #1
0
ファイル: TaskGroup.cs プロジェクト: thoja21/banshee-1
        protected virtual void OnTaskCompletedHandler(object sender, TaskCompletedEventArgs e)
        {
            lock (sync) {
                T t = sender as T;

                try {
                    gsm.SuspendUpdate = true;

                    if (currentTasks.Contains(t))
                    {
                        gsm.DecrementRunningTaskCount();

                        if (t.IsCompleted)
                        {
                            if (!e.Cancelled)
                            {
                                gsm.IncrementCompletedTaskCount();
                            }
                        }
                    }

                    if (t.IsCompleted)
                    {
                        gsm.DecrementRemainingTaskCount();
                    }
                } finally {
                    gsm.SuspendUpdate = false;
                    gsm.Update();
                    OnTaskStopped(t);
                }
            }
        }
コード例 #2
0
        protected virtual void OnTaskCompleted(TaskCompletedEventArgs e)
        {
            AsyncCommandQueue queue = commandQueue;
            EventHandler <TaskCompletedEventArgs> handler = Completed;

            if (queue != null)
            {
                queue.Register(new CommandWrapper(delegate {
                    if (handler != null)
                    {
                        handler(this, e);
                    }
                }));
            }
            else if (handler != null)
            {
                ThreadPool.QueueUserWorkItem(delegate {
                    handler(this, e);
                });
            }
        }
コード例 #3
0
ファイル: EnclosureManager.cs プロジェクト: knocte/banshee
        private void OnDownloadTaskCompletedHandler(object sender, TaskCompletedEventArgs args)
        {
            HttpFileDownloadTask task = sender as HttpFileDownloadTask;
            FeedEnclosure enc = task.UserState as FeedEnclosure;

            if (enc != null) {
                if (args.Error != null || task.Status == TaskStatus.Failed) {
                    enc.DownloadStatus = FeedDownloadStatus.DownloadFailed;
                } else if (!args.Cancelled) {
                    if (task.Status == TaskStatus.Succeeded) {
                        try {
                            enc.SetFileImpl (
                                task.RemoteUri.ToString (),
                                Path.GetDirectoryName (task.LocalPath),
                                task.MimeType,
                                Path.GetFileName (task.LocalPath)
                            );
                        } catch (Exception e) {
                            Log.Error (e);
                            enc.LastDownloadError = FeedDownloadError.DownloadFailed;
                            enc.DownloadStatus = FeedDownloadStatus.DownloadFailed;
                            enc.Save ();
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: Task.cs プロジェクト: knocte/banshee
        protected virtual void OnTaskCompleted(TaskCompletedEventArgs e)
        {
            AsyncCommandQueue queue = commandQueue;
            EventHandler<TaskCompletedEventArgs> handler = Completed;

            if (queue != null) {
                queue.Register (new CommandWrapper (delegate {
                    if (handler != null) {
                        handler (this, e);
                    }
                }));
            } else if (handler != null) {
                ThreadPool.QueueUserWorkItem (delegate {
                    handler (this, e);
                });
            }
        }
コード例 #5
0
        private void OnDownloadCompleted(object sender, TaskCompletedEventArgs args)
        {
            HttpFileDownloadTask task = sender as HttpFileDownloadTask;

            if (task.Status != TaskStatus.Succeeded) {
                task.Completed -= OnDownloadCompleted;

                if (File.Exists (task.LocalPath)) {
                    File.Delete (task.LocalPath);
                }

                if (Directory.Exists (Path.GetDirectoryName (task.LocalPath))) {
                    Directory.Delete (Path.GetDirectoryName (task.LocalPath));
                }

                tasks.Remove (task.LocalPath);

                Hyena.Log.ErrorFormat ("Could not download eMusic track: {0}",
                                       task.Error.ToString());
            } else {
                import_manager.Enqueue (task.LocalPath);
            }
        }