title: CAPL code, putting delay in the code
body: <p>I have a CAPL test code that controls the start of CAN signal sending. My goal is to delay the start of the sending process. 
  My idea to do this is via a setTimer() function in combination with isTimerActive().</p>
  
  <p>In general my code looks the following:</p>
  
  <pre><code>main() {   
  CANstart();
  function_2();
  function_3();   
  }
  
  CANstart() {    
    SetTimer(Delay, 5000); //Timer initialization, set to be 5000ms
  
    while (isTimerActive()==1) {
      // this while loop avoids that the code is proceding while the settimer exception is being called and executed
    }
  
    StartCANTransmitting(); // After this function, jump back to main and proceed with function_2   
  }
  
  on timer Delay {
    // Do nothing, just wait   
  }
  </code></pre>
  
  <p>The program code above lead to being stuck at that point, CANoe does not response and the only way I can end the simulation is via taskmanager. </p>
  
  <ul>
  <li>Further examination from my side lead to the conclusion that the timer need more time to process and is not executed at all.</li>
  <li>Without the isTimerActive() function, the program code does not wait for the timer to finish and there is no delay at all. Seems like the code runs through without waiting for the exception.</li>
  <li>Seems like CAPL handles loops very bad.</li>
  </ul>
  
  <p>I check out stackoverflow and the following forum posts talk about very similar issues that I have without offering any working solutions:</p>
  
  <p><a href="https://stackoverflow.com/questions/30474842/capl-programming-usage-of-timer-as-a-delay">CAPL Programming usage of Timer as a delay</a></p>
  
  <p><a href="https://stackoverflow.com/questions/38048777/are-timers-running-while-loops-are-active">Are timers running, while loops are active?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/47803601/delay-function-in-capl-apart-from-testwaitfortimeout">Delay function in CAPL apart from testwaitfortimeout()</a></p>