Click here to Skip to main content
15,899,634 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Events in .NET 3.0 Pin
Johan Lombaard23-May-07 2:01
Johan Lombaard23-May-07 2:01 
GeneralRe: Events in .NET 3.0 Pin
PrasadHonrao7-Jun-07 21:10
PrasadHonrao7-Jun-07 21:10 
AnswerRe: Events in .NET 3.0 Pin
Kevin McFarlane23-May-07 5:52
Kevin McFarlane23-May-07 5:52 
QuestionMerge 2 Assemblies Pin
jain.ashish2122-May-07 17:12
jain.ashish2122-May-07 17:12 
AnswerRe: Merge 2 Assemblies Pin
Dave Kreskowiak22-May-07 18:03
mveDave Kreskowiak22-May-07 18:03 
GeneralRe: Merge 2 Assemblies Pin
jain.ashish2122-May-07 18:11
jain.ashish2122-May-07 18:11 
GeneralRe: Merge 2 Assemblies Pin
Colin Angus Mackay22-May-07 22:31
Colin Angus Mackay22-May-07 22:31 
QuestionThreading Problem Pin
Hyland Computer Systems22-May-07 15:56
Hyland Computer Systems22-May-07 15:56 
Dear sirs:

I wrote program that performs one resource-intensive operation. This operation is to convert PDF into a text file. I decided to spin-off this single operation on a threading delegate as shown below:

Class Pdf()
{
public delegate string PdfIsbn();

string ISearch.Isbn( string sFileName )
{
m_sFileName = sFileName;
PdfIsbn pdfIsbn = new PdfIsbn( GetIsbn );
IAsyncResult iasResult = pdfIsbn.BeginInvoke( new AsyncCallback( IsbnComplete ) , "Isbn is complete" );

/**********************************
******** Regular Processing *******
**********************************/
// It only works if this code is un-commented.
while (!iasResult.IsCompleted)
{
Console.WriteLine("Please wait...");
//return m_sIsbn;
}

return m_sIsbn;
}

private void IsbnComplete( IAsyncResult iasResult )
{
AsyncResult ar = ( AsyncResult )iasResult;
PdfIsbn pdfIsbn = ( PdfIsbn )ar.AsyncDelegate;
m_sIsbn = pdfIsbn.EndInvoke( iasResult );
Constant.g_iThreadCount -= 1;
}

string GetIsbn()
{
Constant.g_iThreadCount += 1; // Increment thread-counter.
Console.WriteLine( "Pdf version of search implemented" );
Thread.Sleep(5000);
dtSearch dtSrch = new dtSearch( m_sFileName ); // Pass-in filename only.
regEx = new RegEx( "Isbn" ); // Search for a regular expression that fits the "ISBN"-type.
SearchIsbn( regEx , dtSrch.ResultText );
return m_sIsbn = regEx.RegExResult; // Get the ISBN.
}
}

The Main program is a windows form with a DataGridView. The main loop cycles through subfolders; each one containing a PDF.

do
{
try
{
file.GetDirectory(); // gets a book inside a directory, performs search etc.
// If a valid ISBN is found it will show up here.
if (file.SearchItem != "")
{
newBooks.AddBook(new Book(true, file.FileName, file.SearchItem));
}
}

catch (Exception ex)
{
file.LogError(ex, ex.Message.ToString());
}

} while ( file.SubFolder != "sub-folder iteration completed." ) ;

bindingSourceEbookCollection.DataSource = newBooks;
dataGridViewEbookCollection.DataSource = bindingSourceEbookCollection;
dataGridViewEbookCollection.AutoGenerateColumns = true;

I have tried to make the grid "aware" of all of the new book-entries being made inside the collection to which it is bound; to no avail.

I tried using a global "Thread Counter" so that the loop would keep executing until all the threads have been processed; and putting the "grid-binding" code inside the loop with the intent being that it would be "refreshed" with the new book-data.

The way the code is written now, the books show up but only after they have ALL been processed and the grid is blank until the whole process (all books) is completed.

The idea behind "encapsulating" the single, resource-intensive process inside a thread was to show the status of "processing... " inside the data grid for each book that was spun-off on a thread.

Any help is appreciated.

Many thanks,

R. Hyland
AnswerRe: Threading Problem Pin
kubben23-May-07 2:36
kubben23-May-07 2:36 
GeneralRe: Threading Problem [modified] Pin
Hyland Computer Systems23-May-07 14:11
Hyland Computer Systems23-May-07 14:11 
QuestionRun in .Net 2.0 frame work Pin
Tal S.22-May-07 0:27
Tal S.22-May-07 0:27 
AnswerRe: Run in .Net 2.0 frame work Pin
Christian Graus22-May-07 0:38
protectorChristian Graus22-May-07 0:38 
Questioninstalling App in win98 Pin
microuser_200021-May-07 3:10
microuser_200021-May-07 3:10 
AnswerRe: installing App in win98 Pin
Dave Kreskowiak21-May-07 16:13
mveDave Kreskowiak21-May-07 16:13 
AnswerRe: installing App in win98 Pin
Vasudevan Deepak Kumar23-May-07 2:59
Vasudevan Deepak Kumar23-May-07 2:59 
QuestionPictures in WebBrouser control Pin
Zavoloka Sergey20-May-07 19:38
Zavoloka Sergey20-May-07 19:38 
AnswerRe: Pictures in WebBrouser control Pin
Christian Graus20-May-07 19:56
protectorChristian Graus20-May-07 19:56 
QuestionV2.0 vs V3.0 Pin
Ray Cassick20-May-07 10:36
Ray Cassick20-May-07 10:36 
AnswerRe: V2.0 vs V3.0 Pin
Christian Graus20-May-07 11:03
protectorChristian Graus20-May-07 11:03 
GeneralRe: V2.0 vs V3.0 Pin
Ray Cassick20-May-07 11:15
Ray Cassick20-May-07 11:15 
GeneralRe: V2.0 vs V3.0 Pin
Christian Graus20-May-07 12:59
protectorChristian Graus20-May-07 12:59 
QuestionAdo.net with WPF (.Net Framework 3.0) xaml browser application Pin
Nada Adel19-May-07 7:23
Nada Adel19-May-07 7:23 
AnswerRe: Ado.net with WPF (.Net Framework 3.0) xaml browser application Pin
Paul Conrad14-Jul-07 6:52
professionalPaul Conrad14-Jul-07 6:52 
QuestionDetecting if a folder is being copied to... Pin
Christoff91517-May-07 11:17
Christoff91517-May-07 11:17 
AnswerRe: Detecting if a folder is being copied to... Pin
Dave Kreskowiak17-May-07 11:33
mveDave Kreskowiak17-May-07 11:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.