I need to execute some parts of my code in a new thread to improve the performance and the user experience but some of the umbraco.library methods are not working when I execute them in a new thread.
Example: umbraco.library.GetCurrentDomains or umbraco.library.GetNiceUrl
I suppose the problem is that the new thread lose the Umbraco context. Is there any way to create manually the context? Or any other idea?
You could pass an UmbracoHelper instance to your asynchronous method that could be used for retrieving the NiceUrl and NiceUrlWithDomain methods. That would give the thread something to use.
As far as umbraco.library.GetCurrentDomains goes, I don't know what you are using the method for so I don't know what to offer as a workaround. What I can tell you though is that the Domain class that the method used is marked as obsolete in the source on Github so I'm presuming they don't want you to use it.
Problems with MultiThreading
Hello,
I need to execute some parts of my code in a new thread to improve the performance and the user experience but some of the umbraco.library methods are not working when I execute them in a new thread.
Example: umbraco.library.GetCurrentDomains or umbraco.library.GetNiceUrl
I suppose the problem is that the new thread lose the Umbraco context. Is there any way to create manually the context? Or any other idea?
Hi Sergio
Did you find a solution?
I have the exact same problem.
Hey guys,
You could pass an
UmbracoHelper
instance to your asynchronous method that could be used for retrieving theNiceUrl
andNiceUrlWithDomain
methods. That would give the thread something to use.As far as
umbraco.library.GetCurrentDomains
goes, I don't know what you are using the method for so I don't know what to offer as a workaround. What I can tell you though is that theDomain
class that the method used is marked as obsolete in the source on Github so I'm presuming they don't want you to use it.https://github.com/umbraco/Umbraco-CMS/blob/0cca63e6468e02c42bc0f227fff5995c2373f4c8/src/umbraco.cms/businesslogic/web/Domain.cs#L24
Looks like a new
IDomainService
is coming instead for v7.3is working on a reply...