vb.net - Parallel.ForEach to run function on list of items -


i have list of employees populated long string of ids. add them database in parallel speed processing. correct syntax in vb.net use parallel.foreach call function on each item in list. below serial way of doing it.

    dim employees new list(of employee)()     each element string in ids         dim emp new employee(element)         employees.add(emp)     next      each emp in employees         emp.addtodatabase()     next 

the syntax be:

parallel.foreach(employees, sub(emp) emp.addtodatabase()) 

however, it's doubtful doing database inserts in parallel faster. possible speedup in overhead until actual insert, in end database can 1 insert @ time table.

one thing try speed inserts put several inserts in 1 query, i.e. group employees small batches.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -