public async Task IfSequenceIsNull_ThenToListAsyncThrowsArgumentNullException() { IPagedEnumerable <string> seq = null; var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => seq.ToListAsync()); Assert.Equal("source", ex.ParamName); }
public async Task <IList <NodeAgentSku> > ListNodeAgentSkusAsync() { IPagedEnumerable <NodeAgentSku> nodeAgentSkus = this.Service.ListNodeAgentSkus(); IList <NodeAgentSku> results = await nodeAgentSkus.ToListAsync(); return(results); }
/// <summary> /// Lists the task files associated with this task /// </summary> /// <returns></returns> private async System.Threading.Tasks.Task <List <NodeFile> > ListTaskFilesAsync() { IPagedEnumerable <NodeFile> vmFiles = this.Task.ListNodeFiles(recursive: true); List <NodeFile> results = await vmFiles.ToListAsync(); return(results); }
/// <summary> /// Lists the files on this ComputeNode. /// </summary> /// <returns></returns> private async Task <List <NodeFile> > ListFilesAsync() { IPagedEnumerable <NodeFile> vmFiles = this.ComputeNode.ListNodeFiles(recursive: true); List <NodeFile> results = await vmFiles.ToListAsync(); return(results); }
/// <summary> /// Enumerates an enumerable asyncronously if required. If the enumerable is of type IPagedCollection(T) then /// ToListAsync is called on it. Otherwise the enumerable is returned as is. /// </summary> internal static async Task <IEnumerable <T> > EnumerateIfNeededAsync <T>(IEnumerable <T> enumerable, CancellationToken cancellationToken) { IEnumerable <T> result; IPagedEnumerable <T> pagedEnumerable = enumerable as IPagedEnumerable <T>; if (pagedEnumerable != null) { result = await pagedEnumerable.ToListAsync(cancellationToken).ConfigureAwait(false); } else { result = enumerable; } return(result); }
/// <summary> /// Refreshes the status of the ComputeNodes from the Batch service. /// </summary> /// <returns></returns> private async Task RefreshComputeNodesAsync() { // Get the list of pool compute nodess - can't use this because ComputeNode does not support RecentTasks property yet DetailLevel detailLevel = new ODATADetailLevel() { SelectClause = "recentTasks,state,id" }; IPagedEnumerable <ComputeNode> computeNodeEnumerableAsync = this.Pool.ListComputeNodes(detailLevel); List <ComputeNode> computeNodeList = await computeNodeEnumerableAsync.ToListAsync(); this.RunningTasks = 0; this.SchedulableComputeNodes = 0; foreach (ComputeNode computeNode in computeNodeList) { if (computeNode.State == ComputeNodeState.Idle || computeNode.State == ComputeNodeState.Running) { this.SchedulableComputeNodes++; } if (computeNode.State == ComputeNodeState.Running && this.Pool.MaxTasksPerComputeNode == 1) { this.RunningTasks++; } else if (this.Pool.MaxTasksPerComputeNode > 1) { IEnumerable <TaskInformation> taskInfoList = computeNode.RecentTasks; if (taskInfoList != null) { foreach (TaskInformation ti in taskInfoList) { if (ti.TaskState == TaskState.Running) { this.RunningTasks++; } } } } } Interlocked.Exchange(ref this.computeNodes, computeNodeList); //Threadsafe swap }