public void Run()
 {
     IsRunning = true;
     logger.Info("InstanceKeeper [" + InstanceName + "] is running.");
     using (InstanceServiceClient instanceService = new InstanceServiceClient())
     {
         while (IsRunning)
         {
             try
             {
                 logger.Info("Invoking heartbeat...");
                 instanceService.Heartbeat(new InstanceHeartbeatStatus()
                 {
                     InstanceName       = InstanceName,
                     CurrentRunningTask = RunningTask,
                     MaxRunningTask     = MaxRunningTask,
                     SystemStatus       = new NodeSystemStatus()
                     {
                         TotalRamSize     = SysUtil.getTotalRamSize(),
                         AvailableRamSize = SysUtil.getAvailableRamSize(),
                         ProcessCount     = SysUtil.getProcessCount(),
                         LoadAverage      = SysUtil.getLoadAverage()
                     }
                 });
                 logger.Info("Heartbeat sent.");
             }
             catch (FaultException ex)
             {
                 logger.Error("Exception occured during heartbeat: " + ex.Reason);
             }
             try
             {
                 if (RunningTask < MaxRunningTask)
                 {
                     TaskAssignResponse taskAssign = taskService.AssignPendingTask(InstanceName);
                     new Thread(new ThreadStart(delegate()
                     {
                         try
                         {
                             startManager(taskAssign);
                         }
                         catch (Exception e)
                         {
                             logger.Crit("Failed to start task manager: " + e.ToString());
                         }
                     })).Start();
                 }
             }
             catch
             {
                 logger.Debug("No task available. ");
             }
             Thread.Sleep(HeartbeatInterval);
         }
     }
 }