Hello, Just a quick question on the API and retrieving pages while multi threading.
I have a simple Parallel.ForEach loop that retrieves a page from the tree based on the information being looped. This works fine on 1 thread, but as soon as you try run this over multiple threads you get a Object not set to the instance of an object exception.
Below is the piece of code that causes the exception, the tree variable sets fine, but when I try and set the page variable I get the error. All variables used in the query have the correct values, same as when its run on 1 thread.
var tree = new TreeProvider(MembershipContext.AuthenticatedUser);
var page = tree.SelectNodes(className)
Does the kentico tree API allow multi threading? or do I need to call something different to achieve this?
The solution to this was the site context needed to be reinitialised per a thread.
If you set the site and site context on the main thread these will need passing to each thread or re initialising.
Please, sign in to be able to submit a new answer.