2

We are experiencing some problems when accessing items using a Timer which is not consistent for all items. We have the following code:

        var database =Sitecore.Configuration.Factory.GetDatabase(indexItem.TargetDatabase);
        var item = database.GetItem(indexItem.Id, indexItem.Language);

        if(item == null)
        {
            Diagnostics(indexItem.WithDiagnostics, "Item missing in database {0}:{1}:{2}", indexItem.TargetDatabase, indexItem.Id, indexItem.Language);

        }

For the item /sitecore/content/site/home it works, however for the item /sitecore/content/site/home/page1 it fails. This is the same if we access master or web.

Testing the above code in a webpage it works fine for both items on master and web, it just seems to be on the timer event that it fails.

The failure is consistent for each item, i.e. it always fails or it always succeeds.

The time is implemented as follows:

            _processingTimer = new System.Timers.Timer(processingInterval);
            _processingTimer.Elapsed += (obj, args) => ProcessQueue(queueStartParams);
            _processingTimer.AutoReset = true;
            _processingTimer.Start();

Anyone know of any issues related to threading and events in SC?

5
  • How do you implement the Timer? Can you please share it? – Hishaam Namooya May 9 '17 at 10:08
  • added timer code – Michael Edwards May 9 '17 at 10:15
  • 1
    Instead of using a Timer, would it not preferable to make use of a sitecore schedule agent which runs based on the interval you need? – Hishaam Namooya May 9 '17 at 10:17
  • Have you tried with SecurityDisabler? – Marek Musielak May 9 '17 at 11:38
  • I was thinking; how do you persist your Search Context here? are you certain it isn't dropped (.Dispose()'d) at some point while the timed code runs? – Mark Cassidy May 10 '17 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.