コード例 #1
0
        /// <summary>Reads a block of bytes from the stream and writes the data in a given buffer.</summary>
        /// <param name="buffer">When this method returns, contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.</param>
        /// <param name="offset">The byte offset in array at which to begin writing.</param>
        /// <param name="count">The maximum number of bytes to read.</param>
        /// <returns>The total number of bytes read into the buffer. This may be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.</returns>
        public override int Read(byte[] buffer, int offset, int count)
        {
            int temp;

            temp            = fs.Read(buffer, offset, count);
            currentProgress = (int)(((float)Position / (float)Length) * 100.0);

            if ((currentProgress - lastNotifyProgress) >= notifyInterval)
            {
                // Update anyone who's listening.
                if (ProgressUpdate != null)
                {
                    // Package the event arguments.
                    ProgressUpdateEventArgs e = new ProgressUpdateEventArgs();
                    e.PercentDone     = CurrentProgress;
                    e.CurrentPosition = Position;

                    ProgressUpdate(this, e);
                }

                lastNotifyProgress = CurrentProgress;
            }

            return(temp);
        }
コード例 #2
0
 // Got an update from the file stream reading.
 private void fs_ProgressUpdate(object sender, ProgressUpdateEventArgs args)
 {
     OnProgress(currentFile, FileListProcessorStatus.InProcess, args.PercentDone, CalculatePercentage(args.PercentDone));
 }