private void PageantAgent_MessageReceived(object aSender,
Agent.MessageReceivedEventArgs aEventArgs)
{
var mainWindow = pluginHost.MainWindow;
var thread = new Thread(
delegate()
{
mainWindow.Invoke(
(MethodInvoker)delegate()
{
// don't do anything - we are just seeing if the thread is blocked
});
});
thread.Name = "Check";
thread.Start();
// only try to unlock databases if main thread is not blocked
if (thread.Join(1000)) {
mainWindow.Invoke((MethodInvoker)delegate()
{
if (Options.UnlockOnActivity) {
foreach (var document in mainWindow.DocumentManager.Documents) {
if (mainWindow.IsFileLocked(document)) {
mainWindow.OpenDatabase(document.LockedIoc, null, false);
}
}
}
});
} else {
thread.Abort();
}
}