[ Valerij Zajcev @ 28.01.2010. 11:09 ] @
Preko PDFBOX-a ucitavam kolekciju PDF fajlova, i Njihove kompletne tekstove koristim u programu. Problem je taj sto mi u toku ucitavnaja izbaci error: Citat: context switch deadlock was detected The CLR has been unable to transition from COM context 0x1fda00 to COM context 0x1fdc28 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time... Onda sam izbacio ovaj proces na poseban thred (nadam se da je ispravno nikada nisam radio sa thread-ovima): Code: private void button5_Click(object sender, EventArgs e) { ThreadStart threadDelegate = new ThreadStart(ReorderPdfFolder); simpleThread = new System.Threading.Thread(threadDelegate); simpleThread.IsBackground = true; simpleThread.SetApartmentState(ApartmentState.STA); simpleThread.Start(); } Code: private void ReorderPdfFolder() { string pathToUnsortedFolder = null; FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.RootFolder = Environment.SpecialFolder.MyComputer; if (fbd.ShowDialog() == DialogResult.OK) { pathToUnsortedFolder = fbd.SelectedPath; } DirectoryInfo dir = new DirectoryInfo(pathToUnsortedFolder); FileInfo[] filesInCurrentDirectory = dir.GetFiles(); PDDocument pdfDocument; PDFTextStripper pdfStripper = new PDFTextStripper(); List<string> completed = new List<string>(); foreach (FileInfo f in filesInCurrentDirectory) { try { pdfDocument = PDDocument.load(f.FullName); string tempPdfText = pdfStripper.getText(pdfDocument); completed.Add(tempPdfText); } catch (System.Exception) { continue; } } } } Negde na pola rada izbaci mi onaj error odozgo i ja mu kazem continue i on nista nastavi i dalje i zavrsi sve. Problem je sto ne znam kako da izbegnem da taj error ne izbacuje. Zna li neko kako? |