Ejemplo n.º 1
0
        /// <inheritdoc/>
        public Task ExecuteAsync()
        {
            List <Task> tasks = new List <Task>();

            foreach (var entityId in _entityIds)
            {
                dynamic data = new FluentExpandoObject();
                data.entity_id = entityId;
                data.option    = _option;

                tasks.Add(_daemon.CallService("input_select", "select_option", data));
            }

            return(Task.WhenAll(tasks));
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        private async Task CallServiceOnAllEntities(string service)
        {
            var taskList = new List <Task>();

            foreach (var entityId in _entityIds)
            {
                var     domain      = GetDomainFromEntity(entityId);
                dynamic serviceData = new FluentExpandoObject();
                serviceData.entity_id = entityId;
                var task = _daemon.CallService(domain, service, serviceData);
                taskList.Add(task);
            }

            if (taskList.Count > 0)
            {
                await Task.WhenAny(Task.WhenAll(taskList.ToArray()), Task.Delay(5000)).ConfigureAwait(false);
            }
        }