System.ComponentModel.BackgroundWorker.ReportProgress C# (CSharp) Method

ReportProgress() public method

public ReportProgress ( int percentProgress ) : void
percentProgress int
return void
        public void ReportProgress(int percentProgress)
        {
            ReportProgress(percentProgress, null);
        }

Same methods

BackgroundWorker::ReportProgress ( int percentProgress, object userState ) : void

Usage Example

Example #1
1
        private IEnumerable<XElement> AddDirectoryAsync(DirectoryInfo dir, string collectionId, ref int count, int fnumber,
            BackgroundWorker worker)
        {
            List<XElement> addedElements = new List<XElement>();
            // добавление коллекции
            string subCollectionId;
            List<XElement> ae = this.cass.AddCollection(dir.Name, collectionId, out subCollectionId).ToList();
            if (ae.Count > 0) addedElements.AddRange(ae);

            count++;
            foreach (FileInfo f in dir.GetFiles())
            {
                if (worker.CancellationPending) break;
                if (f.Name != "Thumbs.db")
                    addedElements.AddRange(this.cass.AddFile(f, subCollectionId));
                count++;
                worker.ReportProgress(100 * count / fnumber);
            }
            foreach (DirectoryInfo d in dir.GetDirectories())
            {
                if (worker.CancellationPending) break;
                addedElements.AddRange(AddDirectoryAsync(d, subCollectionId, ref count, fnumber, worker));
            }
            return addedElements;
        }
All Usage Examples Of System.ComponentModel.BackgroundWorker::ReportProgress