Windows Store app 8.1 Xaml pausing/resuming download using http classes -


i'm trying use http classes pause/resume download , pausing easy using cancellation token , how can resume download?

i have used background downloader class , had lot of issues in resuming , had many other issues handle downloads.

here code:

 using windows.web.http;  using windows.web.http.filters;  private async void foo(storagefolder folder, string filename) {  uri uri = new uri("http://localhost"); var filter = new httpbaseprotocolfilter(); filter.servercredential =     new windows.security.credentials.passwordcredential(uri.tostring(), "foo", "bar"); var client = new httpclient(filter);  httprequestmessage request = new httprequestmessage(httpmethod.post, uri); request.headers.add("range", "bytes=0-");  // hook progress handler. progress<httpprogress> progresscallback = new progress<httpprogress>(onsendrequestprogress); var tokensource = new cancellationtokensource(); httpresponsemessage response = await client.sendrequestasync(request).astask(tokensource.token, progresscallback);  iinputstream inputstream = await response.content.readasinputstreamasync(); storagefile file = await folder.createfileasync(filename, creationcollisionoption.generateuniquename);  // copy stream stream. ioutputstream outputstream = await file.openasync(fileaccessmode.readwrite); await randomaccessstream.copyandcloseasync(inputstream, outputstream); }  private void onsendrequestprogress(httpprogress obj) {  debug.writeline(obj);  } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -