Click here to Skip to main content
15,921,622 members
Home / Discussions / C#
   

C#

 
AnswerMessage Closed Pin
2-Mar-10 18:35
stancrm2-Mar-10 18:35 
GeneralRe: datagridview insertion Pin
Member 5903102-Mar-10 18:37
Member 5903102-Mar-10 18:37 
AnswerRe: datagridview insertion Pin
Arindam Tewary2-Mar-10 20:16
professionalArindam Tewary2-Mar-10 20:16 
QuestionHow to Create Virtual Drive? Pin
Pawan Kiran2-Mar-10 18:17
Pawan Kiran2-Mar-10 18:17 
AnswerRe: How to Create Virtual Drive? Pin
Saksida Bojan2-Mar-10 18:42
Saksida Bojan2-Mar-10 18:42 
GeneralRe: How to Create Virtual Drive? Pin
Pawan Kiran2-Mar-10 18:57
Pawan Kiran2-Mar-10 18:57 
GeneralRe: How to Create Virtual Drive? Pin
Saksida Bojan2-Mar-10 19:00
Saksida Bojan2-Mar-10 19:00 
QuestionMessage Removed Pin
2-Mar-10 9:09
Kennebel2-Mar-10 9:09 
AnswerRe: WPF Nested Grid Sizing Pin
AspDotNetDev2-Mar-10 17:12
protectorAspDotNetDev2-Mar-10 17:12 
GeneralRe: WPF Nested Grid Sizing Pin
Kennebel3-Mar-10 3:13
Kennebel3-Mar-10 3:13 
QuestionNot sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 8:31
CTaylor892-Mar-10 8:31 
AnswerRe: Not sure why second Access Rule is required for User account write access Pin
DaveyM692-Mar-10 10:22
professionalDaveyM692-Mar-10 10:22 
GeneralRe: Not sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 12:12
CTaylor892-Mar-10 12:12 
AnswerRe: Not sure why second Access Rule is required for User account write access Pin
CTaylor892-Mar-10 13:34
CTaylor892-Mar-10 13:34 
GeneralRe: Not sure why second Access Rule is required for User account write access Pin
DaveyM692-Mar-10 13:56
professionalDaveyM692-Mar-10 13:56 
QuestionWindows Service, FileSystemWatcher + Polling [modified] Pin
krazykoder2-Mar-10 6:23
krazykoder2-Mar-10 6:23 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek2-Mar-10 6:36
Paulo Zemek2-Mar-10 6:36 
If I understood your real intention, I can help.

You will need a HashSet<string>;
A ManualResetEvent;
And two threads.

One thread can look like this:
C#
while(!stopRequested)
{
  GetsAllFilesInTheDirectory
  lock(hashset)
    AddAllFilePathsToTheHashSet.

  if at least one file was added, set the manualResetEvent.

  Wait for some time (a minute?)
}


The other thread will look like this:
C#
while(!stopRequested)
{
  manualResetEvent.WaitOne();

  if (stopRequested)
    break;

  manualResetEvent.Reset();

  lock(hashset)
  {
    foreach(var path in hashset)
    {
      ... do what you need...
    }

    hashset.Clear();
  }
}


And, the event of the file created, you must:
C#
lock(hashset)
  add the path of the file to the hashset.

manualResetEvent.Set();


And that's all.

When finishing your application, you must set stopRequested (which must be volatile) and also must set your manualResetEvent.
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 8:50
mvePIEBALDconsult2-Mar-10 8:50 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek2-Mar-10 9:48
Paulo Zemek2-Mar-10 9:48 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder2-Mar-10 10:55
krazykoder2-Mar-10 10:55 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 12:38
mvePIEBALDconsult2-Mar-10 12:38 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder2-Mar-10 9:23
krazykoder2-Mar-10 9:23 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
Paulo Zemek2-Mar-10 9:39
Paulo Zemek2-Mar-10 9:39 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder3-Mar-10 9:32
krazykoder3-Mar-10 9:32 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek3-Mar-10 13:33
Paulo Zemek3-Mar-10 13: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.