title: blazor-webassembly upload file can't show progress?
body: <p>i want realize a big file upload progress demo,but below code can't working normal.
  if remove the code  &quot;await Task.Delay(1)&quot;  in ProgressableStreamContent class,and id &quot;mybar&quot; element not refresh UI.
  if add &quot;await Task.Delay(1)&quot; ,it's work normal.can refresh UI,show progress.  why?
  Has anyone encountered this problem? Can you help me with this? Thank you.</p>
  <pre class="lang-html prettyprint-override"><code>&lt;p&gt;
      &lt;InputFile OnChange=&quot;@OnInputFileChange&quot; /&gt;
  &lt;/p&gt;
  &lt;div&gt;
      &lt;p&gt;File Size：@totalSize   @progressPercent % &lt;/p&gt;
      @{
          var progressWidthStyle = progressPercent + &quot;%&quot;;
      }
  &lt;div class=&quot;progress&quot;&gt;
      &lt;div id=&quot;mybar&quot; class=&quot;progress-bar&quot; role=&quot;progressbar&quot; style=&quot;width:@progressWidthStyle&quot; area-valuenow=&quot;@progressPercent&quot; aria-minvalue=&quot;0&quot; aria-maxvalue=&quot;100&quot;&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <pre class="lang-cs prettyprint-override"><code>  private CancellationTokenSource cancelation;
      public long totalSize = 0;
      public int progressPercent = 0;
      private string _fileName = &quot;&quot;;
      private async Task OnInputFileChange(InputFileChangeEventArgs e)
      {
          IBrowserFile imageFile = e.File;
          totalSize = imageFile.Size;
          var buffer = new byte[totalSize];
  
  
          await imageFile.OpenReadStream(512000*1000).ReadAsync(buffer);
          var content = new MultipartFormDataContent { { new ByteArrayContent(buffer), &quot;\&quot;upload\&quot;&quot;, e.File.Name } };
  
          var progressContent = new ProgressableStreamContent(content, 10240,
            (sent, total) =&gt;
            {
                progressPercent = (int)(sent * 100 / total);
                Console.WriteLine(&quot;Uploading {0}%&quot;, progressPercent);
              
                StateHasChanged();
            });
          var repsone = await client.PostAsync(&quot;http://localhost:5000/Home/Upload&quot;, progressContent);
          var taskStr = await repsone.Content.ReadAsStringAsync();
          Console.WriteLine(&quot;taskStr=&quot; + taskStr);
      }
  </code></pre>
  <pre><code>  public class ProgressableStreamContent : HttpContent
      {
          /// &lt;summary&gt;
          /// Lets keep buffer of 20kb
          /// &lt;/summary&gt;
          private HttpContent content;
          private int bufferSize;
          //private bool contentConsumed;
          private Action&lt;long, long&gt; progress;
          public ProgressableStreamContent(HttpContent content, int bufferSize, Action&lt;long, long&gt; progress)
          {
              if (content == null)
              {
                  throw new ArgumentNullException(&quot;content&quot;);
              }
              if (bufferSize &lt;= 0)
              {
                  throw new ArgumentOutOfRangeException(&quot;bufferSize&quot;);
              }
  
              this.content = content;
              this.bufferSize = bufferSize;
              this.progress = progress;
  
              foreach (var h in content.Headers)
              {
                  this.Headers.Add(h.Key, h.Value);
              }
          }
  
          protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context)
          {
  
              var buffer = new Byte[this.bufferSize];
              long size;
              TryComputeLength(out size);
              var uploaded = 0;
  
  
              using (var sinput = await content.ReadAsStreamAsync())
              {
                  while (true)
                  {
                      var length = sinput.Read(buffer, 0, buffer.Length);
                      if (length &lt;= 0) break;
  
                      //downloader.Uploaded = uploaded += length;
                      uploaded += length;
                      progress?.Invoke(uploaded, size);
                      await Task.Delay(1);
                      //System.Diagnostics.Debug.WriteLine($&quot;Bytes sent {uploaded} of {size}&quot;);
                  
                      await stream.WriteAsync(buffer, 0, length);
                  }
              }
              stream.Flush();
  
          }
  
          protected override bool TryComputeLength(out long length)
          {
              length = content.Headers.ContentLength.GetValueOrDefault();
              return true;
          }
  
          protected override void Dispose(bool disposing)
          {
              if (disposing)
              {
                  content.Dispose();
              }
              base.Dispose(disposing);
          }
      }
  </code></pre>