/// <summary> /// The moniker calls this method repeatedly to indicate the current progress of the bind /// operation, typically at reasonable intervals during a lengthy operation. /// /// The client can use the progress notification to provide progress information to the /// user from the ulProgress, ulProgressMax, and szStatusText parameters, or to make /// programmatic decisions based on the ulStatusCode parameter. /// </summary> int IBindStatusCallback.OnProgress(uint ulProgress, uint ulProgressMax, BINDSTATUS ulStatusCode, string szStatusText) { //Debug.WriteLine( String.Format( "IBindStatusCallback.OnProgress {0}: {1} ({2}/{3})", ulStatusCode, szStatusText != null ? szStatusText : String.Empty, ulProgress, ulProgressMax ) ) ; // check for timeout if (TimeoutMs != NO_TIMEOUT) { if (DateTime.Now > _timeoutTime) { _timedOut = true; return(HRESULT.E_ABORT); } } if (ulStatusCode == BINDSTATUS.ENDDOWNLOADDATA) { // We've completed the download of the file return(HRESULT.S_OK); } else if (ulStatusCode == BINDSTATUS.MIMETYPEAVAILABLE) { // record the mime type m_contentType = szStatusText; } else if (ulStatusCode == BINDSTATUS.REDIRECTING) { _finalUrl = szStatusText; } else if ((ProgressHost != null && ProgressHost.CancelRequested) || ThreadHelper.Interrupted) { // Cancel this operation return(HRESULT.E_ABORT); } else { if (ProgressHost != null) { // UrlDownloadToFile can sometimes return progress that exceeds 100%- stop this from happening ProgressHost.UpdateProgress((int)(Math.Min(ulProgressMax, ulProgress)), (int)ulProgressMax, String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.ProgressDownloading), Url)); } } return(HRESULT.S_OK); }
/// <summary> /// The moniker calls this method repeatedly to indicate the current progress of the bind /// operation, typically at reasonable intervals during a lengthy operation. /// /// The client can use the progress notification to provide progress information to the /// user from the ulProgress, ulProgressMax, and szStatusText parameters, or to make /// programmatic decisions based on the ulStatusCode parameter. /// </summary> int IBindStatusCallback.OnProgress(uint ulProgress, uint ulProgressMax, BINDSTATUS ulStatusCode, string szStatusText) { //Debug.WriteLine( String.Format( "IBindStatusCallback.OnProgress {0}: {1} ({2}/{3})", ulStatusCode, szStatusText != null ? szStatusText : String.Empty, ulProgress, ulProgressMax ) ) ; // check for timeout if (TimeoutMs != NO_TIMEOUT) { if (DateTime.Now > _timeoutTime) { _timedOut = true; return HRESULT.E_ABORT; } } if (ulStatusCode == BINDSTATUS.ENDDOWNLOADDATA) // We've completed the download of the file return HRESULT.S_OK; else if (ulStatusCode == BINDSTATUS.MIMETYPEAVAILABLE) // record the mime type m_contentType = szStatusText; else if (ulStatusCode == BINDSTATUS.REDIRECTING) _finalUrl = szStatusText; else if ((ProgressHost != null && ProgressHost.CancelRequested) || ThreadHelper.Interrupted) // Cancel this operation return HRESULT.E_ABORT; else { if (ProgressHost != null) // UrlDownloadToFile can sometimes return progress that exceeds 100%- stop this from happening ProgressHost.UpdateProgress((int)(Math.Min(ulProgressMax, ulProgress)), (int)ulProgressMax, String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.ProgressDownloading), Url)); } return HRESULT.S_OK; }