private void StatusUpdateThread_Run()
{
try
{
while (!Created) Thread.Sleep (10);
while (true)
{
SafeInvoke (new MethodInvoker (BeginUpdateListView));
foreach (ScmRepository folder in (SvnFolderCollection) folders.Clone())
{
if (folder.Disable) continue;
updateNotInProgress.WaitOne();
if (forcedCheckForNewVersion)
{
forcedCheckForNewVersion = false;
lastTimeOfCheckForNewVersion = DateTime.Now;
SafeInvoke (new SetStatusBarTextMethod (SetStatusBarText), new object[] {"Checking for new version..."});
CheckForNewVersion (true);
}
bool skipUpdateStatus = false;
// Check commit and update processes for finishing
for (int i = 0; i < ScmRepository.svnFolderProcesses.Count; i++)
{
var sfp = (ScmRepositoryProcess)ScmRepository.svnFolderProcesses[i];
if (sfp.process.HasExited)
{
if (sfp.isUpdateCommand && sfp.updateError)
SafeInvoke (new ShowUpdateErrorsMethod (ShowUpdateErrors), new object[] {sfp}, Int32.MaxValue);
UpdateFolderStatus (sfp.repository);
ScmRepository.svnFolderProcesses.RemoveAt(i--);
}
else if ((folder.Path == sfp.repository.Path) && sfp.isUpdateCommand)
{
skipUpdateStatus = true; // Because updating is still in progress
ScmRepository.ReadProcessOutput (sfp);
}
}
while (forcedFolders.Count > 0)
UpdateFolderStatus ((ScmRepository) forcedFolders.Dequeue());
if ((folder.StatusUpdateTime + new TimeSpan (0, 0, folder.GetInterval (formIsActive)) <= DateTime.Now) && !skipUpdateStatus)
UpdateFolderStatus (folder);
}
if (forcedCheckForNewVersion)
{
forcedCheckForNewVersion = false;
lastTimeOfCheckForNewVersion = DateTime.Now;
SafeInvoke(new SetStatusBarTextMethod(SetStatusBarText), new object[] { "Checking for new version..." });
CheckForNewVersion(true);
}
if (Config.CheckForNewVersion && (lastTimeOfCheckForNewVersion + new TimeSpan(3, 0, 0) < DateTime.Now))
{
lastTimeOfCheckForNewVersion = DateTime.Now;
SafeInvoke (new SetStatusBarTextMethod (SetStatusBarText), new object[] {"Checking for new version..."});
CheckForNewVersion (false);
}
lock (this)
{
if (!reupdateStatus)
{
statusThread = null;
break;
}
else
reupdateStatus = false;
}
}
SafeInvoke (new MethodInvoker (EndUpdateListView));
}
catch (ThreadAbortException)
{
ScmRepository.KillBackgroundProcess();
}
catch (Exception e) // Otherwise it will just lost
{
ShowError ("Error on status thread: " + e);
Application.Exit();
}
}