From batch file, query the task status, and if it is running, keep querying
:loop
for /f "tokens=2 delims=: " %%f in ('schtasks /query /tn yourTaskName /fo list ^| find "Status:"' ) do (
if "%%f"=="Running" (
ping -n 6 localhost >nul 2>nul
goto loop
)
)