title: Delegates And WCF Methods
body: <p>I have successfully designed a large file upload method using WCF. 
  Now, I would like to report progress for each unique file being loaded. 
  In my upload method, i have the following code block:</p>
  
  <pre><code>while ((bytesRead = request.FileByteStream.Read(buffer, 0, bufferSize)) &gt; 0)
  {
      outfile.Write(buffer, 0, bytesRead);
      totalBytesRead += bytesRead; 
  
      if (this.ProgressChanged != null)
          this.ProgressChanged(this, new ProgressArgs(totalBytesRead, request.FileByteStream.Length)); 
  
  }
  </code></pre>
  
  <p>Which uses the deleget ProgressEventHandler as declared below:</p>
  
  <pre><code>public delegate void ProgressEventHandler(object sender, ProgressArgs e);
  public event ProgressEventHandler ProgressChanged; 
  </code></pre>
  
  <p>I do not use delegates all that much (but am trying to learn) and got this far by
  following examples online. The class ProgressArgs was missing from the example but
  I am guessing that is where the calculation takes place and is returned? Something
  like: <code>return Convert.ToInt32((totalBytesRead * 100) / fileSize)</code> ?</p>
  
  <p>So, my questions are thus: </p>
  
  <p>1) Assming I have declared and called my ProgressChanged event correctly, <strong>what do I 
  do with ProgressArgs</strong>? 
  <br>
  <br>
  2) <strong>How do I report progress back to the client</strong>? My WCF method call currently has a 'void' return type: </p>
  
  <p>upload.UploadFile(fileinfo, m_objFile.InputStream); </p>
  
  <p>Will I need to fire a simultaneous JavaScript method that calls a WCF JSON method or something of that nature? A detailed explanation of how to view progress from the client would be seriously appreciated.</p>
  
  <p>Thanks! </p>
  
  <p>PS - I am using ASP.NET 2.0 / Framework 3.5 / C# / and I am self-hosting currently. </p>