public async Task SendKeepAliveAsync(SendKeepAliveRequest sendKeepAliveRequest)
 {
     using (var connection = await CreateNewConnectionAsync(sendKeepAliveRequest.TaskId).ConfigureAwait(false))
     {
         using (var command = new SqlCommand(TaskQueryBuilder.KeepAliveQuery, connection))
         {
             command.CommandTimeout = ConnectionStore.Instance.GetConnection(sendKeepAliveRequest.TaskId).QueryTimeoutSeconds;
             command.Parameters.Add(new SqlParameter("@TaskExecutionId", SqlDbType.Int)).Value = int.Parse(sendKeepAliveRequest.TaskExecutionId);
             await command.ExecuteNonQueryAsync().ConfigureAwait(false);
         }
     }
 }
 public void SendKeepAlive(SendKeepAliveRequest sendKeepAliveRequest)
 {
     using (var connection = CreateNewConnection(sendKeepAliveRequest.TaskId))
     {
         using (var command = new SqlCommand(TaskQueryBuilder.KeepAliveQuery, connection))
         {
             command.CommandTimeout = ConnectionStore.Instance.GetConnection(sendKeepAliveRequest.TaskId).QueryTimeoutSeconds;
             command.Parameters.Add(new SqlParameter("@TaskExecutionId", SqlDbType.Int)).Value = int.Parse(sendKeepAliveRequest.TaskExecutionId);
             command.ExecuteNonQuery();
         }
     }
 }
示例#3
0
        private void StartKeepAlive()
        {
            var keepAliveRequest = new SendKeepAliveRequest()
            {
                TaskId           = new TaskId(_taskExecutionInstance.ApplicationName, _taskExecutionInstance.TaskName),
                TaskExecutionId  = _taskExecutionInstance.TaskExecutionId,
                ExecutionTokenId = _taskExecutionInstance.ExecutionTokenId
            };

            _keepAliveDaemon = new KeepAliveDaemon(_taskExecutionRepository, new WeakReference(this));
            _keepAliveDaemon.Run(keepAliveRequest, _taskExecutionOptions.KeepAliveInterval.Value);
        }
 public void SendKeepAlive(SendKeepAliveRequest sendKeepAliveRequest)
 {
     using (var connection = CreateNewConnection(sendKeepAliveRequest.TaskId))
     {
         using (var command = new SqlCommand(TaskQueryBuilder.KeepAliveQuery, connection))
         {
             command.CommandTimeout = ConnectionStore.Instance.GetConnection(sendKeepAliveRequest.TaskId).QueryTimeoutSeconds;
             command.Parameters.Add(new SqlParameter("@TaskExecutionId", SqlDbType.Int)).Value = int.Parse(sendKeepAliveRequest.TaskExecutionId);
             command.ExecuteNonQuery();
         }
     }
 }
        private void StartKeepAlive(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
        {
            DateTime lastKeepAlive = DateTime.UtcNow;
            _taskExecutionRepository.SendKeepAlive(sendKeepAliveRequest);

            while (!_completeCalled && _owner.IsAlive)
            {
                var timespanSinceLastKeepAlive = DateTime.UtcNow - lastKeepAlive;
                if (timespanSinceLastKeepAlive > keepAliveInterval)
                {
                    lastKeepAlive = DateTime.UtcNow;
                    _taskExecutionRepository.SendKeepAlive(sendKeepAliveRequest);
                }
                Thread.Sleep(1000);
            }
        }
示例#6
0
        private async Task StartKeepAliveAsync(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
        {
            DateTime lastKeepAlive = DateTime.UtcNow;
            await _taskExecutionRepository.SendKeepAliveAsync(sendKeepAliveRequest).ConfigureAwait(false);

            while (!_completeCalled && _owner.IsAlive)
            {
                var timespanSinceLastKeepAlive = DateTime.UtcNow - lastKeepAlive;
                if (timespanSinceLastKeepAlive > keepAliveInterval)
                {
                    lastKeepAlive = DateTime.UtcNow;
                    await _taskExecutionRepository.SendKeepAliveAsync(sendKeepAliveRequest).ConfigureAwait(false);
                }
                await Task.Delay(1000).ConfigureAwait(false);
            }
        }
示例#7
0
        private void StartKeepAlive(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
        {
            DateTime lastKeepAlive = DateTime.UtcNow;

            _taskExecutionRepository.SendKeepAlive(sendKeepAliveRequest);

            while (!_completeCalled && _owner.IsAlive)
            {
                var timespanSinceLastKeepAlive = DateTime.UtcNow - lastKeepAlive;
                if (timespanSinceLastKeepAlive > keepAliveInterval)
                {
                    lastKeepAlive = DateTime.UtcNow;
                    _taskExecutionRepository.SendKeepAlive(sendKeepAliveRequest);
                }
                Thread.Sleep(1000);
            }
        }
示例#8
0
        public void Run(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
        {
            var sendDelegate = new KeepAliveDelegate(StartKeepAlive);

            sendDelegate.BeginInvoke(sendKeepAliveRequest, keepAliveInterval, new AsyncCallback(KeepAliveCallback), sendDelegate);
        }
 public void Run(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
 {
     var sendDelegate = new KeepAliveDelegate(StartKeepAlive);
     sendDelegate.BeginInvoke(sendKeepAliveRequest, keepAliveInterval, new AsyncCallback(KeepAliveCallback), sendDelegate);
 }
示例#10
0
 public void Run(SendKeepAliveRequest sendKeepAliveRequest, TimeSpan keepAliveInterval)
 {
     Task.Run(async() => await StartKeepAliveAsync(sendKeepAliveRequest, keepAliveInterval).ConfigureAwait(false));
 }