Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Using Delegates To Follow Upload Progress Via WCF Method

Reply
Thread Tools

Using Delegates To Follow Upload Progress Via WCF Method

 
 
pbd22
Guest
Posts: n/a
 
      11-04-2009
Hi.

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:

Code:

while ((bytesRead = request.FileByteStream.Read(buffer, 0,
bufferSize)) > 0)
{
outfile.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;

if (this.ProgressChanged != null)
this.ProgressChanged(this, new ProgressArgs(totalBytesRead,
request.FileByteStream.Length));

}



Which uses the delegate ProgressEventHandler as declared below:

Code:

public delegate void ProgressEventHandler(object sender, ProgressArgs
e);
public event ProgressEventHandler ProgressChanged;

I do not use delegates all that much 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:

return Convert.ToInt32((totalBytesRead * 100) / fileSize) ?

So, my questions are thus:

1) Assming I have declared and called my ProgressChanged event
correctly, what is the role of ProgressArgs?

2) How do I report progress back to the client? My WCF method call
currently has a 'void' return type:

Code:

upload.UploadFile(fileinfo, m_objFile.InputStream);

Will I need to fire a simultaneous JavaScript method that calls a WCF
JSON method or something of that nature? If so, it is still unclear to
me how the delegate is used/accessed to report **which file** and
**what precent of it** is being uploaded.

Thanks!

PS - I am using ASP.NET 2.0 / Framework 3.5 / C# / and I am self-
hosting currently.
 
Reply With Quote
 
 
 
 
pbd22
Guest
Posts: n/a
 
      11-05-2009
On Nov 4, 12:06*pm, pbd22 <(E-Mail Removed)> wrote:
> Hi.
>
> 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:
>
> Code:
>
> while ((bytesRead = request.FileByteStream.Read(buffer, 0,
> bufferSize)) > 0)
> {
> * * outfile.Write(buffer, 0, bytesRead);
> * * totalBytesRead += bytesRead;
>
> * * if (this.ProgressChanged != null)
> * * * * this.ProgressChanged(this, new ProgressArgs(totalBytesRead,
> request.FileByteStream.Length));
>
> }
>
> Which uses the delegate ProgressEventHandler as declared below:
>
> Code:
>
> public delegate void ProgressEventHandler(object sender, ProgressArgs
> e);
> public event ProgressEventHandler ProgressChanged;
>
> I do not use delegates all that much 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:
>
> return Convert.ToInt32((totalBytesRead * 100) / fileSize) ?
>
> So, my questions are thus:
>
> 1) Assming I have declared and called my ProgressChanged event
> correctly, what is the role of ProgressArgs?
>
> 2) How do I report progress back to the client? My WCF method call
> currently has a 'void' return type:
>
> Code:
>
> upload.UploadFile(fileinfo, m_objFile.InputStream);
>
> Will I need to fire a simultaneous JavaScript method that calls a WCF
> JSON method or something of that nature? If so, it is still unclear to
> me how the delegate is used/accessed to report **which file** and
> **what precent of it** is being uploaded.
>
> Thanks!
>
> PS - I am using ASP.NET 2.0 / Framework 3.5 / C# / and I am self-
> hosting currently.


Anything else I can add to clarify?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
client to upload big files via https and get progress info News123 Python 9 05-14-2010 07:23 AM
Difference between Ajax Enabled WCF service and regular WCF? Cindy Lee ASP .Net 1 03-19-2010 05:59 PM
AJAX enabled WCF Service Vs Standard WCF Service Simon ASP .Net 0 10-13-2009 09:13 AM
Progress bar to show the progress of a task Charlie Zhang Java 3 08-16-2004 05:53 PM
*Impossible* to build an upload progress meter using ASP.NET. Can you prove me wrong? Brian Birtle ASP .Net 3 10-16-2003 03:53 PM



Advertisments