Click here to Skip to main content
15,917,320 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!!

Thanks

Regards,
Gourav Goyal
Posted
Updated 18-Mar-12 11:47am
v3

 
Share this answer
 
Comments
LanFanNinja 18-Mar-12 18:41pm    
+5
[no name] 18-Mar-12 19:13pm    
Thanks
ProEnggSoft 18-Mar-12 20:31pm    
Good link. +5
[no name] 18-Mar-12 20:31pm    
Thanks
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

Thanks

Regards
Gourav Goyal
What you do is use a background worker, and pass the names of the files back in the ReportProgress. Here is something similar.

C#
public MainWindow()
 {
     InitializeComponent();
     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);
     bw.RunWorkerAsync();

 }

 void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     ItemsSource.Add(e.UserState.ToString());
}

 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; }
 
Share this answer
 

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