[minor] move a line in CommandMonitor
rewrite TaskMonitor similarly to CommandMonitor