hi guys, I'm new to threading basics.
I have a queue of operations to be performed on a XML files(node add,node delete etc)
1]There are 'n' xml files and for each file a thread from thread pool is allocated using ThreadPool.QueueUserWorkItem to do those file operations.
I want to achieve both concurrency and ordering of operation(important) using threads.
eg: Suppose if operations [a1,a2,a3,a4,a5] are to be performed on file "A.xml"
and operations [b1,b2,b3,b4,b5,b6,b7] are to be performed on file "B.xml" .....
I want to allocated threads such that i can perform these operations in the
same order and also concurrently(since files are different).
2]Also is it possible to assign each operation a thread and achieve concurency and preserve order.
In STA model i did something similar..
while(queue.count>0){
File f = queue.Dequeue(); //get File from queue
OperationList oprlst = getOperationsForFile(f);
// will get list-> [a1,a2,a3,a4,a5]
for each Operation oprn in oprlst
{
performOperation(f,oprn)
//in MTA i want to wait till operation "a1" completes and then operation "a2" will
//start.making threads wait till file is in use or operation a(i) is in use.
}
}
i want to do this concurrently with operation order preservation. Threads(of operation) can wait on one file...but Different operations take different execution times.
i tried AutoResetEvent and WaitHandle.WaitAll(..) but it made the while loop stop untill all 'a(i)' operations finish..i want both a(i) and b(j) perform concurrently. (but ordering in a(i) and b(j))
Currently using .net 2.0 .
This is quite similar and is part of this question asked Question