In reply to dave_59:
I understand that I even know it’s illegal to include a task in a function. But what can I do, if I need to run some delay at the end run_test()? I tried to add it in the shutdown phase, but it seems not to work, because I tried to print a debug message and since its running in parallel the message of the shutdown phase is printed at the beginning of the simulation. I also tried post shutdown phase but still the same message happens at the beginning. Is there any alternative solution to this problem?