public WorkerWrapper(IInvokeHandler invokeHandler, NodeConfiguration nodeConfiguration, TrySendNodeStartUpNotificationToManagerTimer nodeStartUpNotificationToManagerTimer, Timer pingToManagerTimer, TrySendJobDoneStatusToManagerTimer trySendJobDoneStatusToManagerTimer, TrySendJobCanceledToManagerTimer trySendJobCanceledStatusToManagerTimer, TrySendJobFaultedToManagerTimer trySendJobFaultedStatusToManagerTimer, TrySendJobDetailToManagerTimer trySendJobDetailToManagerTimer) { _handler = invokeHandler; _nodeConfiguration = nodeConfiguration; WhoamI = _nodeConfiguration.CreateWhoIAm(Environment.MachineName); _nodeStartUpNotificationToManagerTimer = nodeStartUpNotificationToManagerTimer; _nodeStartUpNotificationToManagerTimer.TrySendNodeStartUpNotificationSucceded += NodeStartUpNotificationToManagerTimer_TrySendNodeStartUpNotificationSucceded; _pingToManagerTimer = pingToManagerTimer; _trySendJobDoneStatusToManagerTimer = trySendJobDoneStatusToManagerTimer; _trySendJobCanceledStatusToManagerTimer = trySendJobCanceledStatusToManagerTimer; _trySendJobFaultedStatusToManagerTimer = trySendJobFaultedStatusToManagerTimer; _trySendJobDetailToManagerTimer = trySendJobDetailToManagerTimer; isWorking = false; _trySendJobDetailToManagerTimer.Start(); _nodeStartUpNotificationToManagerTimer.Start(); }
private void SetNodeStatusTimer(TrySendStatusToManagerTimer newTrySendStatusToManagerTimer, JobQueueItemEntity jobQueueItemEntity) { // Stop and dispose old timer. if (_trySendStatusToManagerTimer != null) { _trySendStatusToManagerTimer.Stop(); // Remove event handler. _trySendStatusToManagerTimer.TrySendStatusSucceded -= TrySendStatusToManagerTimer_TrySendStatusSucceded; _trySendStatusToManagerTimer = null; } // Set new timer, if exists. if (newTrySendStatusToManagerTimer != null) { _trySendStatusToManagerTimer = newTrySendStatusToManagerTimer; _trySendStatusToManagerTimer.JobQueueItemEntity = jobQueueItemEntity; _trySendStatusToManagerTimer.TrySendStatusSucceded += TrySendStatusToManagerTimer_TrySendStatusSucceded; _trySendStatusToManagerTimer.Start(); } else { _trySendStatusToManagerTimer = null; } }