{"action":"created","issue":{"url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/2335","labels_url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/2335/labels{/name}","comments_url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/2335/comments","events_url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/2335/events","html_url":"https://github.com/bleroy/OrchardImportTest/issues/2335","id":66186178,"number":2335,"title":"Content manager is not thread-safe","user":{"login":"bleroy","id":1165609,"avatar_url":"https://avatars.githubusercontent.com/u/1165609?v=3","gravatar_id":"","url":"https://api.github.com/users/bleroy","html_url":"https://github.com/bleroy","followers_url":"https://api.github.com/users/bleroy/followers","following_url":"https://api.github.com/users/bleroy/following{/other_user}","gists_url":"https://api.github.com/users/bleroy/gists{/gist_id}","starred_url":"https://api.github.com/users/bleroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleroy/subscriptions","organizations_url":"https://api.github.com/users/bleroy/orgs","repos_url":"https://api.github.com/users/bleroy/repos","events_url":"https://api.github.com/users/bleroy/events{/privacy}","received_events_url":"https://api.github.com/users/bleroy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-03T16:58:37Z","updated_at":"2015-04-03T16:58:38Z","closed_at":null,"body":"I've ran into a couple of random issues when trying to use an instance of\nIContentManager in a parallel loop.  \n  \nSimplest way to repro:  \nTry running a .BuildDisplay(..) method on some list of content items, in\nparallel - items.AsParallel().ForAll({ _contentManager.BuildDisplay(item) });  \n  \nUsing IParallelCacheContext.RunInParallel(...) it's exactly the same.  \n  \nLazy-loading of the DefaultContentManager dependencies is responsible for\nthat. Using the example from above, if you first call\n_contentManager.BuildDisplay(item) on the first item, and run the rest in a\nparallel loop, it's working fine. That's because the lazy loader\n(Lazy<IContentDisplay> in this case) has been evaluated and the value has been\nset in the first call.  \n\nWork Item Details\n--------------------\n**Original CodePlex Issue:**\t[Issue 18445](http://orchard.codeplex.com/workitem/18445)\n**Status:**\tClosed\n**Reason Closed:**\tUnassigned\n**Assigned to:**\tUnassigned\n**Reported on:**\tFeb 19, 2012 at 11:16 PM\n**Reported by:**\tpszmyd\n**Updated on:**\tFeb 22, 2012 at 7:30 PM\n**Updated by:**\tBertrandLeRoy\n**Closed on:**\tFeb 22, 2012 at 7:30 PM\n**Closed by:**\tBertrandLeRoy\n**Status:**\tClosed\n**Reason Closed:**\tUnassigned\n**Assigned to:**\tUnassigned\n**Reported on:**\tFeb 19, 2012 at 11:16 PM\n**Reported by:**\tpszmyd\n**Updated on:**\tFeb 22, 2012 at 7:30 PM\n**Updated by:**\tBertrandLeRoy\n**Closed on:**\tFeb 22, 2012 at 7:30 PM\n**Closed by:**\tBertrandLeRoy\n"},"comment":{"url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/comments/89354018","html_url":"https://github.com/bleroy/OrchardImportTest/issues/2335#issuecomment-89354018","issue_url":"https://api.github.com/repos/bleroy/OrchardImportTest/issues/2335","id":89354018,"user":{"login":"bleroy","id":1165609,"avatar_url":"https://avatars.githubusercontent.com/u/1165609?v=3","gravatar_id":"","url":"https://api.github.com/users/bleroy","html_url":"https://github.com/bleroy","followers_url":"https://api.github.com/users/bleroy/followers","following_url":"https://api.github.com/users/bleroy/following{/other_user}","gists_url":"https://api.github.com/users/bleroy/gists{/gist_id}","starred_url":"https://api.github.com/users/bleroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bleroy/subscriptions","organizations_url":"https://api.github.com/users/bleroy/orgs","repos_url":"https://api.github.com/users/bleroy/repos","events_url":"https://api.github.com/users/bleroy/events{/privacy}","received_events_url":"https://api.github.com/users/bleroy/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T16:58:38Z","updated_at":"2015-04-03T16:58:38Z","body":"On *2012-02-20 08:11:11 UTC*, **@BertrandLeRoy** commented:\n\nI'm not sure about this one. By using AsParallel, aren't you breaking the basic assumption of ASP.NET (and pretty much any web dev platform) that a request runs on a specific thread from beginning to end? It's an assumption that has allowed web frameworks\r\n to be widely adopted and used by developers of all levels. This allows web development to pretty much ignore thread-safety, except for those deep framework pieces that orchestrate the whole thing, and it still scales really well because web servers typically\r\n receive lots of concurrent requests that can be safely dispatched to as many threads, that can run on distinct cores.\r\nBy using AsParallel, you may be applying methods to an environment that doesn't need it, where it is a non-problem. You may also be giving yourself a false impression of better performance as dispatching the work on multiple threads will seem to help on a dev\r\n machine, but may well be detrimental on the actual web server under load.\r\nWhat am I missing?\n"}}