views:

28

answers:

2

Dear All,

I have written a task script using vb.net that have thread used in the code, the problem is how i can know when will be finished all the threads so i can return the success result.

Thanks alot.

A: 

i think you need to use a waitHandle object and the waitAll method

more info here: http://msdn.microsoft.com/en-us/library/system.threading.waithandle.aspx

That being said, I suspect you can refactor the design of your package to let the script task handle the execution, and let SSIS handle the execution scheduling. this gives you the parallelism you want without any of the hassle of multi threaded programming in .net.

a simple setup would be n foreach loops (which execute in serial) each running a partitioned chunk of the work load.

Another simpler option is have the package driven by variables and spawn multiple executions of the package. This could occur across 1-N servers to scale out.

JasonHorner
Yes, what i am doing is as following.1. Read DataTable Records from Database.2. split the Datatable records to 4 parts (for instance, if the DataTable records have 8 records as split as 2,2,2,2 for each new datatable)3. Execute each dataTable in new a Thread and do looping (foreach).4. once the all threads finished i should notify the current thread that was finished and returns succcess.so is this solution suitable for this case??Thanks
In this case, I would use a single data source and then use a conditional split to split the incoming rows into 4 outputs. then I would hook each output up to a task to perform the work needed. SSIS should parallelize this nicely for you, without any custom threading code.
JasonHorner
A: 

Check out a framework I created for threading. It's here.

Josef Richberg