2006-05-23, 05:36 PM
Hi,
Maybe something for the wishlist, but I'll write it down here.
It seems that "LoadRecordingSchedule()" always reads out the recordings from the database when called by the schedule helper instance.
Would it be possible to provide the list as a readonly property, and the list is always kept up to date (so that it actually synchronizes with the database only when it has to)?
I'm asking this because sqlite locks the whole database during a transaction, and the only workaround is to try it again some time later in a Thread.Sleep-loop. And there is no other possibility to get an updated list except calling the LoadRecordingSchedule()-method, even if it was called directly before.
I'll attach some code because I think that it's not that easy to explain, and the code should make clear what I mean.
-alibert
Maybe something for the wishlist, but I'll write it down here.
It seems that "LoadRecordingSchedule()" always reads out the recordings from the database when called by the schedule helper instance.
Would it be possible to provide the list as a readonly property, and the list is always kept up to date (so that it actually synchronizes with the database only when it has to)?
I'm asking this because sqlite locks the whole database during a transaction, and the only workaround is to try it again some time later in a Thread.Sleep-loop. And there is no other possibility to get an updated list except calling the LoadRecordingSchedule()-method, even if it was called directly before.
I'll attach some code because I think that it's not that easy to explain, and the code should make clear what I mean.
Code:
private static void ThreadProc()
{
// don't disturb
databaseWatcher.EnableRaisingEvents = false;
// wait a bit until the transaction is hopefully completed
Thread.Sleep(200);
IList updatedList = null;
while (null == updatedList)
{
try
{
// load schedule from database
updatedList = ScheduleHelper.getInstance().LoadRecordingSchedule();
}
catch (Exception ex)
{
updatedList = null;
Logger.Verbose("Thread: " + ex.Message);
Thread.Sleep(200);
}
}
// new list
recordingSchedule = updatedList;
// update states as well
lock (states)
{
states.Clear();
foreach (ScheduledRecording scheduledRecording in recordingSchedule)
{
if (ScheduledRecording.STATUS_DELETED != scheduledRecording.getRecordingStatus() &&
ScheduledRecording.STATUS_PLACE_HOLDER != scheduledRecording.getRecordingStatus())
{
states[scheduledRecording.getProgramme().getOID()] = scheduledRecording.getRecordingStatus();
}
}
} // lock
MyGuide.NeedRendering = true;
databaseWatcher.EnableRaisingEvents = true;
}
-alibert