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

.NET (Core and Framework)

 
AnswerRe: 1.1 or 2.0 Pin
Luc Pattyn7-Feb-10 2:22
sitebuilderLuc Pattyn7-Feb-10 2:22 
AnswerRe: 1.1 or 2.0 Pin
Luc Pattyn7-Feb-10 8:55
sitebuilderLuc Pattyn7-Feb-10 8:55 
GeneralRe: 1.1 or 2.0 Pin
Roger Wright9-Feb-10 19:11
professionalRoger Wright9-Feb-10 19:11 
GeneralRe: 1.1 or 2.0 Pin
Luc Pattyn10-Feb-10 1:10
sitebuilderLuc Pattyn10-Feb-10 1:10 
GeneralRe: 1.1 or 2.0 Pin
Roger Wright10-Feb-10 2:13
professionalRoger Wright10-Feb-10 2:13 
GeneralRe: 1.1 or 2.0 Pin
Luc Pattyn10-Feb-10 2:53
sitebuilderLuc Pattyn10-Feb-10 2:53 
QuestionIdeas on how to design a file listener Pin
rune7116-Feb-10 7:19
rune7116-Feb-10 7:19 
AnswerRe: Ideas on how to design a file listener Pin
Luc Pattyn6-Feb-10 8:45
sitebuilderLuc Pattyn6-Feb-10 8:45 
Hi,

1.
yes, FileSystemWatcher is rather good at signaling the start of an action, it does not offer a Done event, and the best I ever could find was a loop, trying and waiting some, till success.

2.
hundreds of threads doesn't make sense, they all take a lot of resources. Anyway having multiple threads each copying one or a few files will not help, as soon the disk bandwidth will be the bottleneck. So don't take the multithreading hassle.

3.
the FSW events occur asynchronously, so their handlers aren't running on your main thread, instead they use a ThreadPoolThread. If you copy the file right away, you would be too soon, and also hog the thread. So you will end up using at least two threads: one for the FSW event (probably filling a queue), and one for copying the files, maybe a BackgroundWorker.

4.
Hence my proposal is: use a queue to store the incoming file paths; use a BGW that reads all entries from the queue and copies the files. If the copy fails (it will initially unless the file is really small), let it enqueue the file path again. When all entries have been processed (ignoring the ones requeued), then wait say one second, and repeat. You do need a lock for those queue operations, both at the producer side (FSW event and requeueing) and at the consumer side (BGW dequeue); make sure to keep the lock short, don't do File.Copy within the lock!

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
[The QA section does it automatically now, I hope we soon get it on regular forums as well]


AnswerRe: Ideas on how to design a file listener Pin
Pete O'Hanlon6-Feb-10 10:04
mvePete O'Hanlon6-Feb-10 10:04 
AnswerRe: Ideas on how to design a file listener Pin
Alexey Malyshev7-Feb-10 11:50
Alexey Malyshev7-Feb-10 11:50 
QuestionQSB like Interface Pin
volatil3_5-Feb-10 8:45
volatil3_5-Feb-10 8:45 
QuestionProblem Converting Hex to Decimal Pin
VikashGohil5-Feb-10 3:15
VikashGohil5-Feb-10 3:15 
GeneralRe: Problem Converting Hex to Decimal Pin
harold aptroot5-Feb-10 3:32
harold aptroot5-Feb-10 3:32 
AnswerRe: Problem Converting Hex to Decimal Pin
Ennis Ray Lynch, Jr.5-Feb-10 4:28
Ennis Ray Lynch, Jr.5-Feb-10 4:28 
AnswerRe: Problem Converting Hex to Decimal Pin
Eddy Vluggen5-Feb-10 4:32
professionalEddy Vluggen5-Feb-10 4:32 
AnswerRe: Problem Converting Hex to Decimal Pin
VikashGohil7-Feb-10 2:34
VikashGohil7-Feb-10 2:34 
QuestionUse RegAsm -> SuccessFul but failure in creating object of com wrapped dotnet dll Pin
nlarson114-Feb-10 11:18
nlarson114-Feb-10 11:18 
AnswerRe: Use RegAsm -> SuccessFul but failure in creating object of com wrapped dotnet dll Pin
Eddy Vluggen5-Feb-10 3:37
professionalEddy Vluggen5-Feb-10 3:37 
QuestionInterview questions for web developer Pin
sweety19884-Feb-10 11:05
sweety19884-Feb-10 11:05 
AnswerRe: Interview questions for web developer Pin
Ennis Ray Lynch, Jr.4-Feb-10 11:10
Ennis Ray Lynch, Jr.4-Feb-10 11:10 
AnswerRe: Interview questions for web developer Pin
Not Active4-Feb-10 11:26
mentorNot Active4-Feb-10 11:26 
GeneralRe: Interview questions for web developer Pin
Pete O'Hanlon5-Feb-10 4:51
mvePete O'Hanlon5-Feb-10 4:51 
AnswerRe: Interview questions for web developer Pin
Dave Kreskowiak4-Feb-10 12:51
mveDave Kreskowiak4-Feb-10 12:51 
AnswerRe: Interview questions for web developer Pin
Rozis4-Feb-10 13:29
Rozis4-Feb-10 13:29 
QuestionFile associations in .Net framework library Pin
Edward Diener4-Feb-10 7:39
Edward Diener4-Feb-10 7:39 

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.