Last post Apr 14, 2016 05:02 AM by PaulTheSmith
Apr 13, 2016 09:28 PM|ksureshh_pk|LINK
I am trying to get the data from TFS (with all columns ) for a particular work item type. Using TFS client libraries am able to get the data. but looping through workitems and getting datatable is taking more time (its taking 1hr for 20000 records) because
it has nearly 200 columns and am trying to get all the columns via wi.Fields. below is my code.
foreach(workitem wi in lstworkitems)
foreach(Field fi in wi.Fields)
reading each field and adding a record to the datatable .
The above code is taking more time and when I try to implement multithreading , am getting collection was modified error. I am not modifying collection but am not sure why am getting that error. Also that error is coming only when I loop through wi.Fields
and its not happening when I loop through workitems. .
I was searching on the web for this and few post I got to know we have to implement the thread safe class. but here we are using the WorkItem from client libraries how should we convert this class to thread safe class (couldn't able to understand thread
safe class on few post on the web ) and tried lock too. its still taking more time.
Tried Mulitthreading with thread.start, parallel.foreach, TaskFactory.start(new task) etc.. all the ways am ending up with the same error.
Could you please any one help me how to speed of the process for this case?
Also I tried framing json and converting to datatable and that too taking more time. Please advise how to do this?
Apr 14, 2016 05:02 AM|PaulTheSmith|LINK
I'm pretty sure that multithreading is not going to help you. Multithreading will help when you are CPU bound. You don't seem to be doing much CPU work at all so multithreading would just add complexity for no benefit.
Can you add some detail to this statement
reading each field and adding a record to the datatable
Are you going across the network to get each field individually? If so, you need to stop doing that and get all the fields in one network call - doing that would probably speed your code up by about a factor of 200.
Do you mean an in-memory datatable or are you writing each field separately to a table in a database?