Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Anton 2 posts 22 karma points
    Aug 19, 2010 @ 16:09
    Anton
    0

    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?

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Aug 19, 2010 @ 16:22
    Niels Hartvig
    0

    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). 

  • Anton 2 posts 22 karma points
    Aug 20, 2010 @ 06:19
    Anton
    0

    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!

Please Sign in or register to post replies

Write your reply to:

Draft