Index: trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs	(revision 1371)
+++ trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs	(revision 1379)
@@ -50,7 +50,5 @@
   /// The core component of the Hive Client
   /// </summary>
-  public class Core: MarshalByRefObject {
-    //Todo: Ask wagner
-    public static Object Locker { get; set; }    
+  public class Core: MarshalByRefObject {       
     public static bool abortRequested { get; set; }
         
@@ -65,6 +63,5 @@
     /// Main Method for the client
     /// </summary>
-    public void Start() {
-      Core.Locker = new Object();
+    public void Start() {      
       abortRequested = false;
 
@@ -79,6 +76,7 @@
       wcfService = WcfService.Instance;
       wcfService.LoginCompleted += new EventHandler<LoginCompletedEventArgs>(wcfService_LoginCompleted);
-      wcfService.SendJobCompleted += new EventHandler<SendJobCompletedEventArgs>(wcfService_PullJobCompleted);
-      wcfService.ProcessJobResultCompleted += new EventHandler<ProcessJobResultCompletedEventArgs>(wcfService_SendJobResultCompleted);
+      wcfService.SendJobCompleted += new EventHandler<SendJobCompletedEventArgs>(wcfService_SendJobCompleted);
+      wcfService.StoreFinishedJobResultCompleted += new EventHandler<StoreFinishedJobResultCompletedEventArgs>(wcfService_StoreFinishedJobResultCompleted);
+      wcfService.ProcessSnapshotCompleted += new EventHandler<ProcessSnapshotCompletedEventArgs>(wcfService_ProcessSnapshotCompleted);
       wcfService.ConnectionRestored += new EventHandler(wcfService_ConnectionRestored);
       wcfService.ServerChanged += new EventHandler(wcfService_ServerChanged);
@@ -105,5 +103,5 @@
         DetermineAction(container);
       }
-    }
+    }    
 
     /// <summary>
@@ -127,7 +125,5 @@
         //Snapshot is ready and can be sent back to the Server
         case MessageContainer.MessageType.SnapshotReady:
-          ThreadPool.QueueUserWorkItem(new WaitCallback(GetSnapshot), container.JobId);
-          //Thread ssr = new Thread(new ParameterizedThreadStart(GetSnapshot));
-          //ssr.Start(container.JobId);          
+          ThreadPool.QueueUserWorkItem(new WaitCallback(GetSnapshot), container.JobId);          
           break;
         //Pull a Job from the Server
@@ -137,7 +133,5 @@
         //A Job has finished and can be sent back to the server
         case MessageContainer.MessageType.FinishedJob:
-          ThreadPool.QueueUserWorkItem(new WaitCallback(GetFinishedJob), container.JobId);
-          //Thread finThread = new Thread(new ParameterizedThreadStart(GetFinishedJob));
-          //finThread.Start(container.JobId);          
+          ThreadPool.QueueUserWorkItem(new WaitCallback(GetFinishedJob), container.JobId);          
           break;     
         //Hard shutdown of the client
@@ -158,5 +152,5 @@
 
         if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin) {
-          wcfService.ProcessJobResultAsync(ConfigManager.Instance.GetClientInfo().ClientId,
+          wcfService.StoreFinishedJobResultAsync(ConfigManager.Instance.GetClientInfo().ClientId,
             jId,
             sJob,
@@ -166,5 +160,5 @@
         } else {          
           JobStorageManager.PersistObjectToDisc(wcfService.ServerIP, wcfService.ServerPort, jId, sJob);
-          lock (Core.Locker) {
+          lock (engines) {
             AppDomain.Unload(appDomains[jId]);
             appDomains.Remove(jId);
@@ -182,5 +176,5 @@
       long jId = (long)jobId;
       byte[] obj = engines[jId].GetSnapshot();
-      wcfService.ProcessJobResultAsync(ConfigManager.Instance.GetClientInfo().ClientId,
+      wcfService.ProcessSnapshotAsync(ConfigManager.Instance.GetClientInfo().ClientId,
         jId,
         obj,
@@ -202,5 +196,5 @@
     }    
 
-    void wcfService_PullJobCompleted(object sender, SendJobCompletedEventArgs e) {
+    void wcfService_SendJobCompleted(object sender, SendJobCompletedEventArgs e) {
       if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {
         bool sandboxed = true;
@@ -209,5 +203,5 @@
         AppDomain appDomain = PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.Job.Id.ToString(), sandboxed, typeof(TestJob));
         appDomain.UnhandledException += new UnhandledExceptionEventHandler(appDomain_UnhandledException);
-        lock (Locker) {                    
+        lock (engines) {                    
           if (!jobs.ContainsKey(e.Result.Job.Id)) {
             jobs.Add(e.Result.Job.Id, e.Result.Job);
@@ -228,21 +222,17 @@
     }
     
-    //Todo: Seperate this method into 2: Finished jobs and Snapshots
-    void wcfService_SendJobResultCompleted(object sender, ProcessJobResultCompletedEventArgs e) {
+
+    void wcfService_StoreFinishedJobResultCompleted(object sender, StoreFinishedJobResultCompletedEventArgs e) {
       if (e.Result.Success) {        
-        lock (Locker) {
+        lock(engines) {        
           //if the engine is running again -> we sent an snapshot. Otherwise the job was finished
           //this method has a risk concerning race conditions.
           //better expand the sendjobresultcompltedeventargs with a boolean "snapshot?" flag
-          if (e.Result.finished == false) {
-            Logging.Instance.Info(this.ToString(), "Snapshot for Job " + e.Result.JobId + " transmitted");
-          } else {
-            AppDomain.Unload(appDomains[e.Result.JobId]);
-            appDomains.Remove(e.Result.JobId);
-            engines.Remove(e.Result.JobId);
-            jobs.Remove(e.Result.JobId);
-            ClientStatusInfo.JobsProcessed++;
-            Debug.WriteLine("ProcessedJobs to:" + ClientStatusInfo.JobsProcessed);
-          }
+          AppDomain.Unload(appDomains[e.Result.JobId]);
+          appDomains.Remove(e.Result.JobId);
+          engines.Remove(e.Result.JobId);
+          jobs.Remove(e.Result.JobId);
+          ClientStatusInfo.JobsProcessed++;
+          Debug.WriteLine("ProcessedJobs to:" + ClientStatusInfo.JobsProcessed);
         }        
       } else {        
@@ -251,8 +241,12 @@
     }
 
+    void wcfService_ProcessSnapshotCompleted(object sender, ProcessSnapshotCompletedEventArgs e) {
+      Logging.Instance.Info(this.ToString(), "Snapshot " + e.Result.JobId + " has been transmitted according to plan");
+    }
+
     //Todo: First stop all threads, then terminate
     void wcfService_ServerChanged(object sender, EventArgs e) {
       Logging.Instance.Info(this.ToString(), "ServerChanged has been called");
-      lock (Locker) {
+      lock (engines) {
         foreach (KeyValuePair<long, AppDomain> entries in appDomains)
           AppDomain.Unload(appDomains[entries.Key]);
