.NET Framework Developer Center > .NET Development Forums > .NET Base Class Library > Background worker thread for scanning file
Ask a questionAsk a question
 

AnswerBackground worker thread for scanning file

  • Thursday, November 05, 2009 10:50 PMOdomaeB Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    I have a WPF application with a menu option to kick off file scanning for certain keywords when the file is being written to the USB drive. I have the filter driver in place. I need to kick off a background thread that would wait infinitely for messages from the filter driver and according call the scan function. I used

                 AVworker = new BackgroundWorker();
                 AVworker.DoWork += AVworker_Dowork;

    Within the AVworker_DoWork() function, I need to wait indefinitely for messages from the filter and process them. I need this thread to exit when the application is killed.

    How do I do the wait in the background?

    I tried an alternative method. When the menu option was invoked, I called unmanaged scan() function(part of a .dll) which in turn invoked a thread which did the waiting using WaitForMultipleObjects(). However, in this case, the application became unresponsive because of the wait. Hence I want to do the same in the background without using a while (1) kind of loop.

Answers

All Replies