3

This is a common question around multi threading in Orchard.

I have a module with a controller providing an action to execute a DB synchronization which takes a very long time. The action basically executes a for loop over several hundred items whereas each item could be processed / synchronized independently.

While researching how to improve performance i came across several possible solutions

  • async / await keyword
  • parallel for loop
  • Orchard.Environment.Work<>
  • Orchard.Caching.IParallelCacheContext
  • Orchard.Caching.ITask
  • async controller actions (also combined with the return value Task<>)

and many more.

What would be the best way to improve performance of the for loop without bypassing possible optimizations already implemented / provided in Orchard?

ViRuSTriNiTy
  • 5,017
  • 2
  • 32
  • 58
  • 1
    What is your bottle neck? – Szymon Seliga Feb 11 '16 at 13:37
  • @Szymonides At the time i posted this question i had to optimize a synchronization task that was executed in a controller action of a module, see http://stackoverflow.com/a/35230193/3936440. But then i thought it would be good idea to ask a common question as i didn't found anything on the net about threading in connection with Orchard. – ViRuSTriNiTy Feb 11 '16 at 15:18
  • It is almost never a good idea to spin new threads from an ASP.NET app. – Bertrand Le Roy Feb 25 '16 at 00:42

1 Answers1

0
Community
  • 1
  • 1
ViRuSTriNiTy
  • 5,017
  • 2
  • 32
  • 58