<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to display Progress Status while uploading/ downloading a file ( in .Net ) ? in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-Progress-Status-while-uploading-downloading-a/m-p/172104#M6543</link>
    <description>&lt;P&gt;This looks like a continuation of your question from &lt;A href="https://www.dropboxforum.com/hc/en-us/community/posts/206986286-How-to-get-Progress-Status-while-uploading-downloading-a-file-in-Net-#community_comment_210175303" target="_blank" rel="nofollow noreferrer"&gt;your other thread&lt;/A&gt;.&amp;nbsp;As I mentioned there, this part isn't about Dropbox, so I can't offer any help. Also, this probably isn't the best forum for getting help for questions like this. You may want to try StackOverflow, or a forum for .NET.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 00:54:12 GMT</pubDate>
    <dc:creator>Greg-DB</dc:creator>
    <dc:date>2016-06-23T00:54:12Z</dc:date>
    <item>
      <title>How to display Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-Progress-Status-while-uploading-downloading-a/m-p/172103#M6542</link>
      <description>&lt;P&gt;I have tried with downloading and uploading functions, it gives the progress data alright, but I can not set that data to progress bar. I have worked with couple of hours but can not place that process status in the progress bar or any other way. I have attached codes of Upload&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;private async Task ChunkUpload()&lt;BR /&gt;{&lt;/P&gt;
&lt;PRE&gt;string path = UploadFolder + "/" + UploadFile;&lt;BR /&gt; FileStream stream = UploadFileStream;&lt;BR /&gt; int chunkSize = 128 * 1024;&lt;BR /&gt; &lt;BR /&gt; DropboxClient dbx = new DropboxClient(SystemVariables.WebAcccessToken);&lt;BR /&gt; int numChunks = (int)Math.Ceiling((double)stream.Length / chunkSize);&lt;BR /&gt; byte[] buffer = new byte[chunkSize];&lt;BR /&gt; string sessionId = null;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; for (var idx = 0; idx &amp;lt; numChunks; idx++)&lt;BR /&gt; {&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; var byteRead = stream.Read(buffer, 0, chunkSize);&lt;BR /&gt;&lt;BR /&gt; using (var memSream = new MemoryStream(buffer, 0, byteRead))&lt;BR /&gt; {&lt;BR /&gt; if (idx == 0)&lt;BR /&gt; {&lt;BR /&gt; var result = await dbx.Files.UploadSessionStartAsync(false, memSream);&lt;BR /&gt; sessionId = result.SessionId;&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; var cursor = new UploadSessionCursor(sessionId, (ulong)(chunkSize * idx));&lt;BR /&gt; var percentage = 100 * ((chunkSize * idx) / (double)stream.Length);&lt;BR /&gt; pValue = (int)Math.Ceiling((decimal)percentage);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; // Approach 1&lt;BR /&gt;&lt;BR /&gt; &lt;STRONG&gt;var progressIndicator = new Progress&amp;lt;int&amp;gt;(ReportProgress);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; int uploads = await UploadProgress(progressIndicator);&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;PRE&gt;// Approach 2&lt;/PRE&gt;
&lt;PRE&gt;&lt;BR /&gt;&lt;STRONG&gt; /*&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; Thread t = new Thread(new ThreadStart(this.DoProcess));&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; t.Start();&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; while (t.IsAlive) // while thread is running&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; Application.DoEvents(); // Allow UI to refresh if needed&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt; Thread.Sleep(10000); // sleep a while to avoid processor load&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; t.Abort();&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; }*/&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt; if (idx == numChunks - 1)&lt;BR /&gt; {&lt;BR /&gt; await dbx.Files.UploadSessionFinishAsync(cursor, new CommitInfo(path), memSream);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; await dbx.Files.UploadSessionAppendV2Async(cursor,false, memSream);&lt;BR /&gt; &lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; public delegate void UpdateProgressBarDelegate(int progress);&lt;BR /&gt; public UpdateProgressBarDelegate UpdateProgressBar;&lt;BR /&gt;&lt;BR /&gt; private void UpdateProgressBarMethod(int progress)&lt;BR /&gt; {&lt;BR /&gt; IAsyncResult result = this.progressBar1.BeginInvoke(&lt;BR /&gt; (MethodInvoker)delegate()&lt;BR /&gt; {&lt;BR /&gt; progressBar1.Value = progress;&lt;BR /&gt; Text = progress.ToString();&lt;BR /&gt; //txtLogDetails.Text = message; &lt;BR /&gt;&lt;BR /&gt; });&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;private void DoProcess()&lt;BR /&gt; {&lt;BR /&gt; UpdateProgressBarMethod(pValue);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void ReportProgress(int value)&lt;BR /&gt; {&lt;BR /&gt; progressBar1.Value = value;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; async Task&amp;lt;int&amp;gt; UploadProgress(IProgress&amp;lt;int&amp;gt; progress)&lt;BR /&gt; {&lt;BR /&gt; int processCount = await Task.Run&amp;lt;int&amp;gt;(() =&amp;gt;&lt;BR /&gt; {&lt;BR /&gt; if (progress != null)&lt;BR /&gt; {&lt;BR /&gt; progress.Report(pValue);&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt; return pValue;&lt;BR /&gt; });&lt;BR /&gt; return processCount;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can see the 2 approaches that I have tried to update progress bar value,&lt;BR /&gt;but can not see the update in progress bar.&lt;BR /&gt;&lt;BR /&gt;It will be great if you provide the detail code for display updates in progress bar from the scrat&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 09:32:30 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-Progress-Status-while-uploading-downloading-a/m-p/172103#M6542</guid>
      <dc:creator>RAJIB N.</dc:creator>
      <dc:date>2019-05-29T09:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to display Progress Status while uploading/ downloading a file ( in .Net ) ?</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-Progress-Status-while-uploading-downloading-a/m-p/172104#M6543</link>
      <description>&lt;P&gt;This looks like a continuation of your question from &lt;A href="https://www.dropboxforum.com/hc/en-us/community/posts/206986286-How-to-get-Progress-Status-while-uploading-downloading-a-file-in-Net-#community_comment_210175303" target="_blank" rel="nofollow noreferrer"&gt;your other thread&lt;/A&gt;.&amp;nbsp;As I mentioned there, this part isn't about Dropbox, so I can't offer any help. Also, this probably isn't the best forum for getting help for questions like this. You may want to try StackOverflow, or a forum for .NET.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 00:54:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/How-to-display-Progress-Status-while-uploading-downloading-a/m-p/172104#M6543</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2016-06-23T00:54:12Z</dc:date>
    </item>
  </channel>
</rss>

