title: How to get CANoe TestModule status to see if it is still running or tests are finished? (TestModule.OnStop event handling)
body: <p>I am working on C# CLI application that will have to load test configuration to CANoe, start the tests, get the verdict and then load another configuration and repeat the steps.
  So far I can load configuration, start the tests, get the verdict but I can't get the information whether the test are finished already or it is still running.
  I thought that  TestEnvironment.TestModules[&quot;Test&quot;].Verdict will return value &quot;0|cVerdictNotAvailable &quot; as long as the tests are running but it returns &quot;1|cVerdictPassed&quot; since the test are started.
  I went through the COM interface help pages and what I learned is that the only way to get info regarding finishe test is to handle the TestModule.OnStop event. And here comes the troubles - I am not that good in coding in C# :(
  I am adding some functions to already existing framework and basing on one of the functions that handles Measurement.OnStart event I tried to handle TestModule.OnStop but it doesn't seem to work.
  I don't fully understand how to use the delegate in this usecase and how to handle this event to also get the stop reason from this event. I would really appreciate any advices and hints.
  Here is what I &quot;coded&quot;(I also add the code I based on):</p>
  <pre><code>    /// &lt;summary&gt;
      /// This Delgate will be called as soon as CANoe will be initialized
      /// &lt;/summary&gt;
      public delegate void DelCanoeOnInitHandler(CANoe.CAPL caplObj);
      public delegate void DelTestModuleOnStopHandler(CANoe.TSTestModule testModuleObj);
  
      public static class xxx {
          private static DelCanoeOnInitHandler canoeOnInitHandler = null;
          private static DelTestModuleOnStopHandler testModuleOnStopHandler = null;
          
  
          public static void CANoe_TestModuleStoppedEvent(CANoe.eTestModuleStopReason reason)
          {
  
              CANoe.TestEnvironment testEnvironments = GetTestEnvironment();
              CANoe.TSTestModule testModule = (CANoe.TSTestModule)TestEnvironment.TestModules[&quot;xx&quot;];
              testModuleOnStopHandler?.Invoke(testModule);
              Console.WriteLine(&quot;Reason of stop: &quot; + reason.ToString());
  
          }
  
  
          public static void StartTest(DelTestModuleOnStopHandler OnStopEventHandler = null)
          {
  
              TestEnvironment = GetTestEnvironment();
              CANoe.TSTestModule testModule = (CANoe.TSTestModule)TestEnvironment.TestModules[&quot;xx&quot;];
              try
              {
                  CANoeWrapper.StartMeasurement();
                  logger?.Info(&quot;CANoe measurement started.&quot;);
                  try
                  {
                      testModule.Start();
                      logger?.Info(&quot;Tests started.&quot;);
                      //testModule.OnStop += new CANoe._ITSTestModuleEvents_OnStopEventHandler(CANoe_TestModuleStoppedEvent);
                      if (OnStopEventHandler != null)
                      {
                          testModuleOnStopHandler = OnStopEventHandler;
  
                          testModule.OnStop += new CANoe._ITSTestModuleEvents_OnStopEventHandler(CANoe_TestModuleStoppedEvent);
                      }
                  }
                  catch (Exception ex)
                  {
                      logger?.Error(ex.Message);
                      logger?.Error(&quot;Test start failed&quot;);
                      //throw;
                  }
  
  
              }
              catch (Exception e)
              {
                  logger?.Error(e.Message);
                  logger?.Error(&quot;CANoe measurement start failed.&quot;);
                  //throw;
              }
          }
  }
  }
  </code></pre>
  <p>And in the Main() I call it this way:
  <code>xxx.StartTest()</code></p>
  <p>Should I put any parameter in <code>xxx.StartTest(_____)</code> ?</p>
  <p>I would really need some help with this so thanks in advance!
  Pawel</p>