protected virtual void OnProgressChanged(DownloadEventArguments args)
 {
     lock (this.m_myLock)
     {
         this.m_downloadState = args.State;
         this.m_progress      = (int)args.Progress;
         if (this.m_downloadState != EDownloadTaskState.DLTaskDownloading)
         {
             if (this.m_downloadState != EDownloadTaskState.DLTaskPaused)
             {
                 if (this.m_downloadState != EDownloadTaskState.DLTaskPending)
                 {
                     if (this.m_downloadState != EDownloadTaskState.DLTaskPendingAttach)
                     {
                         this.m_downloadTask  = null;
                         this.m_downloadState = this.GetDownloadState();
                     }
                 }
             }
         }
     }
     Application.DeferredInvoke(new DeferredInvokeHandler(this.UpdateCommandState), DeferredInvokePriority.Normal);
 }
        private void UpdateState(object args)
        {
            this.Progress = -1f;
            float progress;

            if (args != null)
            {
                DownloadEventArguments downloadEventArguments = (DownloadEventArguments)args;
                this.m_downloadState = downloadEventArguments.State;
                progress             = downloadEventArguments.Progress;
            }
            else
            {
                this.m_downloadState = this.m_downloadTask.GetState();
                progress             = this.m_downloadTask.GetProgress();
            }
            switch (this.m_downloadState)
            {
            case EDownloadTaskState.DLTaskPendingAttach:
            case EDownloadTaskState.DLTaskPending:
                this.Description = Shell.LoadString(StringId.IDS_PENDING);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskDownloading:
                this.UpdateProgress(Guid.Empty, progress);
                if (this.SecondsToProgressivePlayback == 0)
                {
                    this.Description = Shell.LoadString(StringId.IDS_PLAY_SONG);
                }
                else
                {
                    this.Description = string.Format(Shell.LoadString(StringId.IDS_DOWNLOAD_PROGRESS), (int)progress);
                }
                this.Available = true;
                break;

            case EDownloadTaskState.DLTaskPaused:
                this.Description = string.Format(Shell.LoadString(StringId.IDS_DOWNLOAD_PROGRESS), (int)progress);
                this.Progress    = progress / 100f;
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskCancelled:
                this.Description = Shell.LoadString(StringId.IDS_CANCELLED);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskFailed:
                this.Description = Shell.LoadString(StringId.IDS_FAILED);
                this.Available   = false;
                break;

            case EDownloadTaskState.DLTaskComplete:
                this.Description = Shell.LoadString(StringId.IDS_INCOLLECTION);
                this.Available   = true;
                break;

            default:
                this.Description = Shell.LoadString(StringId.IDS_PENDING);
                this.Available   = false;
                break;
            }
        }
 private void OnProgressChanged(DownloadEventArguments args) => Application.DeferredInvoke(new DeferredInvokeHandler(this.UpdateState), args, DeferredInvokePriority.Normal);