public async Task <IActionResult> Index() { var url = new Uri(Url.Action("RevaleeCalled", "Home", null, Request.Scheme)); var callback = await _revalee.RequestCallbackAsync(url, DateTime.Now.AddMinutes(1)); return(View()); }
internal async Task Start() { if (CallbackBaseUri != null) { if (!IsActive) { if (_heartbeatTimer == null) { // Schedule a heartbeat on a timer lock (_taskCollection) { if (_heartbeatTimer == null) { _heartbeatTimer = new Timer(delegate(object self) { try { if (IsActive) { lock (_taskCollection) { if (_heartbeatTimer != null) { _heartbeatTimer.Dispose(); _heartbeatTimer = null; } } } else { if (_heartbeatTimer == null)// || AppDomain.CurrentDomain.IsFinalizingForUnload()) { return; } int failureCount = Interlocked.Increment(ref _heartbeatCount) - 1; lock (_taskCollection) { if (_heartbeatTimer != null) { if (_heartbeatCount > 20) { // Leave current timer setting in-place } else if (_heartbeatCount > 13) { _heartbeatTimer.Change(3600000, 14400000); } else if (_heartbeatCount > 3) { _heartbeatTimer.Change(60000, 60000); } else if (_heartbeatCount > 2) { _heartbeatTimer.Change(49750, 60000); } } } if (failureCount > 0) { OnActivationFailure(failureCount); } try { var id = _revalee.RequestCallbackAsync(GenerateHeartbeatCallbackUri(), _clockSource.Now).Result; } catch (RevaleeRequestException) { // Ignore network errors and retry based on the timer schedule } } } catch (Exception ex) { // Ignore errors when already shutting down } }, null, 250, 10000); } } } else { // Schedule an on-demand heartbeat await Schedule(this.PrepareHeartbeat()); } } } }