Limit execution time in SharePoint Timer Job?
I have a situation where I need to move some huge data using a timer job. But I can't do this using OneTimeSchedule as it may impact the performance of my sharepoint application during the peak hours.
I want to make it run for maximum of 5 hours a day starting at 20:00 everyday.
What is the best wa开发者_高级运维y?
You could create a SharePoint timer job. Make the timer job run every day at a given time. Inside the job you use a System.Threading.Timer to stop the main loop after five hours and exit the job. Within the main loop you move the data - you should make sure that you somehow persist the state of that main loop. So in case the job crashes or a severe error occurs it can continue processing where it stopped. I hope it helps...
精彩评论