public void FireStateChange(int processId, ProcessState newState) { try { vertexScheduler.ProcessChangeState(processId, newState); } catch (Exception e) { DryadLogger.LogError(0, e, "Failed to change state to {0} for process {1}", newState.ToString(), processId); } }
object IValueConverter.Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { try { ProcessState state = value != null ? (ProcessState)value : ProcessState.Unprocessed; string key = state.ToString(); return(CulturesHelper.GetTextValue(key));; } catch (Exception) { return(Binding.DoNothing); } }
public ProcessState MoveNext(Command command) { CurrentState = GetNext(command); MessageBox.Show(CurrentState.ToString()); return(CurrentState); }
public void ChangeState(ProcessState newState) { lock (SyncRoot) { if (newState > m_currentState) { DryadLogger.LogDebug("Change State", "Transition process {0} from state {1} to state {2}", m_id, m_currentState, newState); m_currentState = newState; List <ProcessState> listenersToRemove = new List <ProcessState>(); List <ProcessState> waitersToRemove = new List <ProcessState>(); // Check for listeners / waiters for earlier states, in case a state is skipped (e.g. process failed to start) foreach (ProcessState s in m_stateChangeListeners.Keys) { if (s <= m_currentState) { // Notify listeners if (m_stateChangeListeners[s] != null) { XComputeProcessStateChangeEventArgs e = new XComputeProcessStateChangeEventArgs(m_id, m_currentState, false); m_stateChangeListeners[s](this, e); if (m_stateChangeTimers.ContainsKey(m_stateChangeListeners[s])) { m_stateChangeTimers[m_stateChangeListeners[s]].Dispose(); m_stateChangeTimers.Remove(m_stateChangeListeners[s]); } } listenersToRemove.Add(s); } } foreach (ProcessState s in listenersToRemove) { m_stateChangeListeners.Remove(s); } foreach (ProcessState s in m_stateChangeWaiters.Keys) { // Signal waiters if (s <= m_currentState) { foreach (ManualResetEvent w in m_stateChangeWaiters[s]) { w.Set(); } waitersToRemove.Add(s); } } foreach (ProcessState s in waitersToRemove) { foreach (ManualResetEvent e in m_stateChangeWaiters[s]) { try { e.Close(); } catch (Exception ex) { DryadLogger.LogError(0, ex); } } m_stateChangeWaiters.Remove(s); } if (m_currentState == ProcessState.AssignedToNode) { m_assignedToNodeEvent.Set(); } } else { DryadLogger.LogWarning("Change State", "Unexpected state change attempted for process {0}: from {1} to {2}", this.m_id, this.m_currentState.ToString(), newState.ToString()); } } }
public void ChangeState(ProcessState newState) { lock (SyncRoot) { if (newState > m_currentState) { DryadLogger.LogDebug("Change State", "Transition process {0} from state {1} to state {2}", m_id, m_currentState, newState); m_currentState = newState; List<ProcessState> listenersToRemove = new List<ProcessState>(); List<ProcessState> waitersToRemove = new List<ProcessState>(); // Check for listeners / waiters for earlier states, in case a state is skipped (e.g. process failed to start) foreach (ProcessState s in m_stateChangeListeners.Keys) { if (s <= m_currentState) { // Notify listeners if (m_stateChangeListeners[s] != null) { XComputeProcessStateChangeEventArgs e = new XComputeProcessStateChangeEventArgs(m_id, m_currentState, false); m_stateChangeListeners[s](this, e); if (m_stateChangeTimers.ContainsKey(m_stateChangeListeners[s])) { m_stateChangeTimers[m_stateChangeListeners[s]].Dispose(); m_stateChangeTimers.Remove(m_stateChangeListeners[s]); } } listenersToRemove.Add(s); } } foreach (ProcessState s in listenersToRemove) { m_stateChangeListeners.Remove(s); } foreach (ProcessState s in m_stateChangeWaiters.Keys) { // Signal waiters if (s <= m_currentState) { foreach (ManualResetEvent w in m_stateChangeWaiters[s]) { w.Set(); } waitersToRemove.Add(s); } } foreach (ProcessState s in waitersToRemove) { foreach (ManualResetEvent e in m_stateChangeWaiters[s]) { try { e.Close(); } catch (Exception ex) { DryadLogger.LogError(0, ex); } } m_stateChangeWaiters.Remove(s); } if (m_currentState == ProcessState.AssignedToNode) { m_assignedToNodeEvent.Set(); } } else { DryadLogger.LogWarning("Change State", "Unexpected state change attempted for process {0}: from {1} to {2}", this.m_id, this.m_currentState.ToString(), newState.ToString()); } } }
public void DebugLog(string str) { var msg = (str.Length < 1 ? " " : " => " + str); Debug.LogFormat("({0}:{1}){2}", name, mState.ToString(), msg); }