public void PollToCompletion() { try { DateTime startTime = DateTime.Now; int lastDebug = 0; log.InfoFormat("Started polling task {0}", _action.RelatedTask.opaque_ref); log.DebugFormat("Polling for action {0}", _action.Description);//log once we start while (!taskCompleted) { if (AsyncAction.ForcedExiting && !_action.SafeToExit) { throw new CancelledException(); } //then log every 30seconds int currDebug = (int)((DateTime.Now - startTime).TotalSeconds) / 30; if (currDebug > lastDebug) { lastDebug = currDebug; log.DebugFormat("Polling for action {0}", _action.Description); } Poll(); Thread.Sleep(SLEEP_TIME); } } finally { _action.DestroyTask(); } }