/// <summary> /// Event handler action that executes the scheduled action. /// </summary> /// <param name="context">Additional contextual information.</param> private void executeActions(NSFEventContext context) { if ((Name != null) && (Name != String.Empty)) { NSFTraceLog.PrimaryTraceLog.addTrace(NSFTraceTags.ActionExecutedTag, NSFTraceTags.ActionTag, Name); } Actions.execute(context); }
/// <summary> /// Reaction that performs the work of writing to the console. /// </summary> /// <param name="context">Additional contextual information.</param> private void performWriteToConsole(NSFEventContext context) { Console.Write(((NSFDataEvent <NSFString>)context.Event).Data); lastWriteOnSeparateLine = false; lock (debugUtilityMutex) { --pendingWriteCount; } }
/// <summary> /// Reaction that does the work of saving the file. /// </summary> /// <param name="context">Additional contextual information.</param> protected void saveTrace(NSFEventContext context) { try { addTrace(NSFTraceTags.InformationalTag, NSFTraceTags.NameTag, TraceSaveString); xmlLog.save(((NSFDataEvent <NSFString>)context.Event).Data); addTrace(NSFTraceTags.InformationalTag, NSFTraceTags.NameTag, TraceSaveCompleteString); } catch (Exception e) { // If unable to save a trace, just add a trace with the exception message, because calling the exception handler may result in an infinite loop addTrace(NSFTraceTags.ExceptionTag, NSFTraceTags.MessageTag, Name + " exception saving trace: " + e.ToString()); } }
void testEventAction(NSFEventContext context) { NSFTime currentTime = NSFTimerThread.PrimaryTimerThread.CurrentTime; if (lastTime == 0) { lastTime = currentTime; return; } NSFTime deltaTime = currentTime - lastTime; // Record max and min observed delta times if (deltaTime > maxDeltaTime) { maxDeltaTime = deltaTime; } if (deltaTime < minDeltaTime) { minDeltaTime = deltaTime; } // Record current time as last time through loop lastTime = currentTime; }
/// <summary> /// Reaction that does the work adding a trace element to the log. /// </summary> /// <param name="context">Additional contextual information.</param> protected void addTraceToLog(NSFEventContext context) { try { xmlLog.jumpToRootElement(); int numberOfChildElements; while (xmlLog.getNumberOfChildElements(out numberOfChildElements) && (numberOfChildElements >= maxTraces)) { xmlLog.deleteChildElementFront(); } xmlLog.addChildElementBack(((NSFDataEvent <NSFXMLElement>)context.Event).Data); } catch { // If unable to add a trace, just do nothing, because calling the exception handler may result in an infinite loop } }
/// <summary> /// Reaction that does the work of saving the file. /// </summary> /// <param name="context">Additional contextual information.</param> protected void saveTrace(NSFEventContext context) { try { addTrace(NSFTraceTags.InformationalTag, NSFTraceTags.NameTag, TraceSaveString); xmlLog.save(((NSFDataEvent<NSFString>)context.Event).Data); addTrace(NSFTraceTags.InformationalTag, NSFTraceTags.NameTag, TraceSaveCompleteString); } catch (Exception e) { // If unable to save a trace, just add a trace with the exception message, because calling the exception handler may result in an infinite loop addTrace(NSFTraceTags.ExceptionTag, NSFTraceTags.MessageTag, Name + " exception saving trace: " + e.ToString()); } }
/// <summary> /// Reaction that does the work adding a trace element to the log. /// </summary> /// <param name="context">Additional contextual information.</param> protected void addTraceToLog(NSFEventContext context) { try { xmlLog.jumpToRootElement(); int numberOfChildElements; while (xmlLog.getNumberOfChildElements(out numberOfChildElements) && (numberOfChildElements >= maxTraces)) { xmlLog.deleteChildElementFront(); } xmlLog.addChildElementBack(((NSFDataEvent<NSFXMLElement>)context.Event).Data); } catch { // If unable to add a trace, just do nothing, because calling the exception handler may result in an infinite loop } }
/// <summary> /// Reaction that performs the work of writing to the console. /// </summary> /// <param name="context">Additional contextual information.</param> private void performWriteToConsole(NSFEventContext context) { Console.Write(((NSFDataEvent<NSFString>)context.Event).Data); lastWriteOnSeparateLine = false; lock (debugUtilityMutex) { --pendingWriteCount; } }