Add wait for activity.

Fix #332