/// <summary> /// worker method for the resumable update /// </summary> /// <param name="data"></param> /// <param name="asyncOp"></param> /// <param name="completionMethodDelegate"></param> /// <returns></returns> private void AsyncUpdateWorker(AsyncResumableUploadData data, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate) { try { if (data.Entry != null) { using (var response = Update(data.Authentication, data.Entry, data)) { HandleResponseStream(data, response.GetResponseStream(), -1); } } else { using (var response = Update(data.Authentication, data.UriToUse, data.DataStream, data.ContentType, data)) { HandleResponseStream(data, response.GetResponseStream(), -1); } } } catch (Exception e) { data.Exception = e; } this.CompletionMethodDelegate(data); }
public void UpdateAsync(Authenticator authentication, AbstractEntry payload, object userData) { AsyncResumableUploadData data = new AsyncResumableUploadData(this, authentication, payload, HttpMethods.Put, this.ProgressReportDelegate, userData); WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncUpdateWorker); this.AsyncStarter(data, workerDelegate, userData); }
public void ResumeAsync(Authenticator authentication, Uri resumeUri, String httpmethod, Stream payload, string contentType, object userData) { AsyncResumableUploadData data = new AsyncResumableUploadData(this, authentication, resumeUri, payload, contentType, null, httpmethod, this.ProgressReportDelegate, userData); WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncResumeWorker); this.AsyncStarter(data, workerDelegate, userData); }
public void InsertAsync(Authenticator authentication, Uri resumableUploadUri, Stream payload, string contentType, string slug, object userData) { AsyncResumableUploadData data = new AsyncResumableUploadData(this, authentication, resumableUploadUri, payload, contentType, slug, HttpMethods.Post, this.ProgressReportDelegate, userData); WorkerResumableUploadHandler workerDelegate = new WorkerResumableUploadHandler(AsyncInsertWorker); this.AsyncStarter(data, workerDelegate, userData); }
/// <summary> /// starts the async job /// </summary> /// <param name="data"></param> /// <param name="userData"></param> /// <param name="workerDelegate"></param> /// <returns></returns> private void AsyncStarter(AsyncResumableUploadData data, WorkerResumableUploadHandler workerDelegate, Object userData) { AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userData); data.Operation = asyncOp; AddUserDataToDictionary(userData, asyncOp); // Start the asynchronous operation. workerDelegate.BeginInvoke( data, asyncOp, this.CompletionMethodDelegate, null, null); }