I’m wondering if there’s any way to call library.RefreshContent() synchronously? I’m using LINQ to Umbraco and want to make sure that the Umbraco.config have been refreshed before I instantiate my DataContext class.
I’ve looked at the code and found that library.RefrechContent() calls content.RefreshContentFromDatabaseAsync(). In content.RefreshContentFromDatabaseAsync() a delegate is created and queued using the thread pool. Shortly after the FireAfterRefreshContent event is raised. The problem is that if the delegate takes a long time to finish, the FireAfterRefreshContent event will be raised prematurely. So hooking to FireAfterRefreshContent won’t do it. Or am I missing something?
I’d like to stick with the Umbraco API. Is there an alternative to library.RefreshContent() that updates the Umbraco.config and block execution until it’s finished?
I'm assuming that you're making some content changes via the API and wants to use LINQ 2 Umbraco in the same request. That won't work (L2U would use the previous data as the content is persisted after the request have finished).
You could call umbraco.content.PersistXmlToFile() (in the umbraco.dll assembly) after your API changes (this would however cause the umbraco.config to be persisted twice but that's not a biggie, really).
I must have looked for that method for at least 10 min before I realized I had opened an old umbraco.dll. Loaded up one of the later ones and there it was. Thanks!
Call library.RefreshContent() synchronously
I’m wondering if there’s any way to call library.RefreshContent() synchronously? I’m using LINQ to Umbraco and want to make sure that the Umbraco.config have been refreshed before I instantiate my DataContext class.
I’ve looked at the code and found that library.RefrechContent() calls content.RefreshContentFromDatabaseAsync(). In content.RefreshContentFromDatabaseAsync() a delegate is created and queued using the thread pool. Shortly after the FireAfterRefreshContent event is raised. The problem is that if the delegate takes a long time to finish, the FireAfterRefreshContent event will be raised prematurely. So hooking to FireAfterRefreshContent won’t do it. Or am I missing something?
I’d like to stick with the Umbraco API. Is there an alternative to library.RefreshContent() that updates the Umbraco.config and block execution until it’s finished?
I'm assuming that you're making some content changes via the API and wants to use LINQ 2 Umbraco in the same request. That won't work (L2U would use the previous data as the content is persisted after the request have finished).
You could call umbraco.content.PersistXmlToFile() (in the umbraco.dll assembly) after your API changes (this would however cause the umbraco.config to be persisted twice but that's not a biggie, really).
I must have looked for that method for at least 10 min before I realized I had opened an old umbraco.dll. Loaded up one of the later ones and there it was. Thanks!
is working on a reply...