Click here to Skip to main content
15,899,026 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek2-Mar-10 6:36
Paulo Zemek2-Mar-10 6:36 
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 
Thanks Paulo,

Been reading up on threading a bit and still looking into using your solution.

Still have a few more questions...


while(!stopRequested)
{  
	manualResetEvent.WaitOne();  
	if (stopRequested)    
		break;  
	manualResetEvent.Reset();  
	lock(hashset)  
	{    
		foreach(var path in hashset)    
		{
			... do what you need...    
		}    
		hashset.Clear();  
	}
}


... do what you need...

1) if it locks that hashset and then loops thru and processes
the files 1 by 1 (which could potentially take a couple minutes a file)
then wont the other threads need to sit and wait until they can obtain the lock on the hashset? For some reason to me that seems like it is defeating the purpose of using the extra thread that processes the files.

If the thread that processes the files is running and locks the hashset for 5 minutes say, and 5 more files get dropped into the IN directory causing 5 more filesystemwatcher.fileCreated events to happen, the 1st one will be waiting to obtain a lock on the hashset and the other 4 events will be waiting in line (and filling up the file system watcher buffer) won't they?

I was trying to avoid doing much work in the filesystemwatcher.fileCreated event (as many seem to suggests) to stop it from bottlenecking and filling it's buffer and cause events to get lost.

Maybe I'm missing something, but seems like if it sits there and waits for lock to become available, it could have just done the work itself.


Maybe I can alter the logic to lock hashset, get 1st file, unlock hashset, process the file, lock hashset, remove the file just processed from hashset , unlock hashset, loop again.

Does that make any sense or is this not a legit concern?
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek3-Mar-10 13:33
Paulo Zemek3-Mar-10 13:33 
GeneralRe: Windows Service, FileSystemWatcher + Polling [modified] Pin
krazykoder4-Mar-10 6:26
krazykoder4-Mar-10 6:26 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder4-Mar-10 8:41
krazykoder4-Mar-10 8:41 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
Paulo Zemek4-Mar-10 16:05
Paulo Zemek4-Mar-10 16:05 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
krazykoder5-Mar-10 4:36
krazykoder5-Mar-10 4:36 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
PIEBALDconsult2-Mar-10 8:44
mvePIEBALDconsult2-Mar-10 8:44 
AnswerRe: Windows Service, FileSystemWatcher + Polling Pin
Pete O'Hanlon2-Mar-10 10:23
mvePete O'Hanlon2-Mar-10 10:23 
GeneralRe: Windows Service, FileSystemWatcher + Polling Pin
#realJSOP3-Mar-10 3:54
professional#realJSOP3-Mar-10 3:54 
QuestionOUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:20
chiky_ancutza2-Mar-10 5:20 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Dan Mos2-Mar-10 5:24
Dan Mos2-Mar-10 5:24 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:28
chiky_ancutza2-Mar-10 5:28 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Dan Mos2-Mar-10 5:38
Dan Mos2-Mar-10 5:38 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Luc Pattyn2-Mar-10 5:29
sitebuilderLuc Pattyn2-Mar-10 5:29 
AnswerRe: OUTLFLTR.DLL library - need an answer Pin
Covean2-Mar-10 5:33
Covean2-Mar-10 5:33 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 5:45
chiky_ancutza2-Mar-10 5:45 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
Covean2-Mar-10 5:58
Covean2-Mar-10 5:58 
GeneralRe: OUTLFLTR.DLL library - need an answer Pin
chiky_ancutza2-Mar-10 7:27
chiky_ancutza2-Mar-10 7:27 

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.