Index: trunk/sources/HeuristicLab.CEDMA.DB/Database.cs
===================================================================
--- trunk/sources/HeuristicLab.CEDMA.DB/Database.cs	(revision 398)
+++ trunk/sources/HeuristicLab.CEDMA.DB/Database.cs	(revision 399)
@@ -36,13 +36,15 @@
   public class Database : IDatabase {
     private string connectionString;
-    private ReaderWriterLockSlim rwLock;
+    private ReaderWriterLockSlim agentLock;
+    private ReaderWriterLockSlim resultLock;
     public Database(string connectionString) {
       this.connectionString = connectionString;
-      rwLock = new ReaderWriterLockSlim();
+      agentLock = new ReaderWriterLockSlim();
+      resultLock = new ReaderWriterLockSlim();
     }
 
     #region create empty database
     public void CreateNew() {
-      rwLock.EnterWriteLock();
+      agentLock.EnterWriteLock();
       try {
         using(DbConnection cnn = new SQLiteConnection(connectionString)) {
@@ -68,5 +70,5 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        agentLock.ExitWriteLock();
       }
     }
@@ -75,5 +77,5 @@
     #region insert agent/result/sub-result
     public long InsertAgent(long? parentAgentId, string name, byte[] rawData) {
-      rwLock.EnterWriteLock();
+      agentLock.EnterWriteLock();
       try {
         using(DbConnection cnn = new SQLiteConnection(connectionString)) {
@@ -107,10 +109,10 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        agentLock.ExitWriteLock();
       }
     }
 
     public long InsertResult(long agentId, string summary, string description, byte[] rawData) {
-      rwLock.EnterWriteLock();
+      resultLock.EnterWriteLock();
       try {
         using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
@@ -149,10 +151,10 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        resultLock.ExitWriteLock();
       }
     }
 
     public long InsertSubResult(long resultId, string summary, string description, byte[] rawData) {
-      rwLock.EnterWriteLock();
+      resultLock.EnterWriteLock();
       try {
         using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
@@ -191,5 +193,5 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        resultLock.ExitWriteLock();
       }
     }
@@ -198,5 +200,5 @@
     #region update agent/run
     public void UpdateAgent(long id, string name) {
-      rwLock.EnterWriteLock();
+      agentLock.EnterWriteLock();
       try {
         using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
@@ -220,10 +222,10 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        agentLock.ExitWriteLock();
       }
     }
 
     public void UpdateAgent(long id, ProcessStatus status) {
-      rwLock.EnterWriteLock();
+      agentLock.EnterWriteLock();
       try {
         using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
@@ -247,10 +249,10 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        agentLock.ExitWriteLock();
       }
     }
 
     public void UpdateAgent(long id, byte[] rawData) {
-      rwLock.EnterWriteLock();
+      agentLock.EnterWriteLock();
       try {
         using(SQLiteConnection cnn = new SQLiteConnection(connectionString)) {
@@ -274,5 +276,5 @@
         }
       } finally {
-        rwLock.ExitWriteLock();
+        agentLock.ExitWriteLock();
       }
     }
@@ -283,5 +285,5 @@
 
     public ICollection<AgentEntry> GetAgents(ProcessStatus status) {
-      rwLock.EnterReadLock();
+      agentLock.EnterReadLock();
       List<AgentEntry> agents = new List<AgentEntry>();
       try {
@@ -306,5 +308,5 @@
         }
       } finally {
-        rwLock.ExitReadLock();
+        agentLock.ExitReadLock();
       }
       return agents;
@@ -312,5 +314,5 @@
 
     public ICollection<AgentEntry> GetAgents() {
-      rwLock.EnterReadLock();
+      agentLock.EnterReadLock();
       List<AgentEntry> agents = new List<AgentEntry>();
       try {
@@ -333,5 +335,5 @@
         }
       } finally {
-        rwLock.ExitReadLock();
+        agentLock.ExitReadLock();
       }
       return agents;
@@ -339,5 +341,5 @@
 
     public ICollection<AgentEntry> GetSubAgents(long parentAgentId) {
-      rwLock.EnterReadLock();
+      agentLock.EnterReadLock();
       List<AgentEntry> agents = new List<AgentEntry>();
       try {
@@ -365,5 +367,5 @@
         }
       } finally {
-        rwLock.ExitReadLock();
+        agentLock.ExitReadLock();
       }
       return agents;
@@ -372,5 +374,5 @@
     public ICollection<ResultEntry> GetResults(long agentId) {
       List<ResultEntry> results = new List<ResultEntry>();
-      rwLock.EnterReadLock();
+      resultLock.EnterReadLock();
       try {
         using(DbConnection cnn = new SQLiteConnection(connectionString)) {
@@ -397,5 +399,5 @@
         }
       } finally {
-        rwLock.ExitReadLock();
+        resultLock.ExitReadLock();
       }
       return results;
@@ -404,5 +406,5 @@
     public ICollection<ResultEntry> GetSubResults(long resultId) {
       List<ResultEntry> results = new List<ResultEntry>();
-      rwLock.EnterReadLock();
+      resultLock.EnterReadLock();
       try {
         using(DbConnection cnn = new SQLiteConnection(connectionString)) {
@@ -429,5 +431,5 @@
         }
       } finally {
-        rwLock.ExitReadLock();
+        resultLock.ExitReadLock();
       }
       return results;
