Click here to Skip to main content
15,175,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I am developing a desktop application on c# .net for .pdf file managing. A problem occur when i search any folder for .pdf, my application stopm responding for some time. I use xmlwriter to write data(i.e. file name,author name,subject).Also i have a label to show current scanning of file but it only show last file after complition of scanning. Please help!!


Gourav Goyal
Updated 18-Mar-12 12:47pm

LanFanNinja 18-Mar-12 18:41pm
[no name] 18-Mar-12 19:13pm
ProEnggSoft 18-Mar-12 20:31pm
Good link. +5
[no name] 18-Mar-12 20:31pm
GoyalGourav 19-Mar-12 9:43am
Hi Wes Aday,
I did it by using backgroundworker. But a problem persist, when i reading current scanning through label it gave me error "Cross-thread operation not valid: Control 'label2' accessed from a thread other than the thread it was created on". Any clue why it is showing that error


Gourav Goyal
GoyalGourav 19-Mar-12 6:54am
Thanks, it work great for me
What you do is use a background worker, and pass the names of the files back in the ReportProgress. Here is something similar.

public MainWindow()
     ItemsSource = new ObservableCollection<string>() { "pme", "two", 3.ToString() };
     DataContext = this;
     var bw = new BackgroundWorker();
     bw.DoWork += new DoWorkEventHandler(bw_DoWork);
     bw.WorkerReportsProgress = true;
     bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);


 void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)

 void bw_DoWork(object sender, DoWorkEventArgs e)
     var bw = (BackgroundWorker) sender;
     for (int i = 1; i < 10000; i++)
         bw.ReportProgress(i / 10000, i);

 public ObservableCollection<string> ItemsSource { get; set; }

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900