Aracılığıyla paylaş


CloudJob.AddTask Method

Definition

Overloads

AddTask(CloudTask, IEnumerable<BatchClientBehavior>)

Adds a single task to this CloudJob. To add multiple tasks, use JobOperations.AddTaskAsync.

AddTask(IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type, IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>)

Adds tasks to a job.

AddTask(CloudTask, IEnumerable<BatchClientBehavior>)

Source:
CloudJob.cs

Adds a single task to this CloudJob. To add multiple tasks, use JobOperations.AddTaskAsync.

public System.Collections.Concurrent.ConcurrentDictionary<Type,Microsoft.Azure.Batch.IFileStagingArtifact> AddTask (Microsoft.Azure.Batch.CloudTask taskToAdd, System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.BatchClientBehavior> additionalBehaviors = default);
member this.AddTask : Microsoft.Azure.Batch.CloudTask * seq<Microsoft.Azure.Batch.BatchClientBehavior> -> System.Collections.Concurrent.ConcurrentDictionary<Type, Microsoft.Azure.Batch.IFileStagingArtifact>
Public Function AddTask (taskToAdd As CloudTask, Optional additionalBehaviors As IEnumerable(Of BatchClientBehavior) = Nothing) As ConcurrentDictionary(Of Type, IFileStagingArtifact)

Parameters

taskToAdd
CloudTask

The CloudTask to add.

additionalBehaviors
IEnumerable<BatchClientBehavior>

A collection of BatchClientBehavior instances that are applied to the Batch service request after the CustomBehaviors.

Returns

A collection of information about the file staging process (see FilesToStage). For more information see IFileStagingArtifact.

Remarks

Each call to this method incurs a request to the Batch service. Therefore, using this method to add multiple tasks is less efficient than using a bulk add method, and can incur HTTP connection restrictions. If you are performing many of these operations in parallel and are seeing client side timeouts (a TaskCanceledException), please see http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit%28v=vs.110%29.aspx or use AddTask(String, IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>).

This is a blocking operation. For a non-blocking equivalent, see AddTaskAsync(CloudTask, ConcurrentDictionary<Type,IFileStagingArtifact>, IEnumerable<BatchClientBehavior>, CancellationToken).

Applies to

AddTask(IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type, IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>)

Source:
CloudJob.cs

Adds tasks to a job.

public void AddTask (System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.CloudTask> tasksToAdd, Microsoft.Azure.Batch.BatchClientParallelOptions parallelOptions = default, System.Collections.Concurrent.ConcurrentBag<System.Collections.Concurrent.ConcurrentDictionary<Type,Microsoft.Azure.Batch.IFileStagingArtifact>> fileStagingArtifacts = default, TimeSpan? timeout = default, System.Collections.Generic.IEnumerable<Microsoft.Azure.Batch.BatchClientBehavior> additionalBehaviors = default);
member this.AddTask : seq<Microsoft.Azure.Batch.CloudTask> * Microsoft.Azure.Batch.BatchClientParallelOptions * System.Collections.Concurrent.ConcurrentBag<System.Collections.Concurrent.ConcurrentDictionary<Type, Microsoft.Azure.Batch.IFileStagingArtifact>> * Nullable<TimeSpan> * seq<Microsoft.Azure.Batch.BatchClientBehavior> -> unit
Public Sub AddTask (tasksToAdd As IEnumerable(Of CloudTask), Optional parallelOptions As BatchClientParallelOptions = Nothing, Optional fileStagingArtifacts As ConcurrentBag(Of ConcurrentDictionary(Of Type, IFileStagingArtifact)) = Nothing, Optional timeout As Nullable(Of TimeSpan) = Nothing, Optional additionalBehaviors As IEnumerable(Of BatchClientBehavior) = Nothing)

Parameters

tasksToAdd
IEnumerable<CloudTask>

The CloudTasks to add.

parallelOptions
BatchClientParallelOptions

Controls the number of simultaneous parallel AddTaskCollection requests issued to the Batch service. Each AddTaskCollection request contains at most MaxTasksInSingleAddTaskCollectionRequest tasks in it. Also controls the cancellation token for the operation. If omitted, the default is used (see BatchClientParallelOptions.)

fileStagingArtifacts
ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>

An optional collection to receive information about the file staging process (see FilesToStage). An entry is added to the ConcurrentBag<T> for each set of tasks grouped for submission to the Batch service. Unlike single-task adds, you cannot use this parameter to customize the file staging process. For more information about the format of each entry, see IFileStagingArtifact.

timeout
Nullable<TimeSpan>

The amount of time after which the operation times out.

additionalBehaviors
IEnumerable<BatchClientBehavior>

A collection of BatchClientBehavior instances that are applied to the Batch service request after the CustomBehaviors.

Exceptions

Thrown if one or more requests to the Batch service fail.

Remarks

This is a blocking operation; for a non-blocking equivalent, see AddTaskAsync(IEnumerable<CloudTask>, BatchClientParallelOptions, ConcurrentBag<ConcurrentDictionary<Type,IFileStagingArtifact>>, Nullable<TimeSpan>, IEnumerable<BatchClientBehavior>).

This method is not atomic; that is, it is possible for the method to start adding tasks and then fail. The collection of tasks to add is broken down into chunks of size at most MaxTasksInSingleAddTaskCollectionRequest, and an AddTaskCollection request is issued for each chunk. Requests may be issued in parallel according to the parallelOptions.

Issuing a large number of simultaneous requests to the Batch service can incur HTTP connection restrictions. If you are performing many of these operations in parallel (or have specified a large MaxDegreeOfParallelism in the parallelOptions) and are seeing client side timeouts (a TaskCanceledException), please see http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit%28v=vs.110%29.aspx .

The progress of the operation in the face of errors is determined by AddTaskCollectionResultHandler behavior. You do not normally need to specify this behavior, as the Batch client uses a default which works in normal circumstances. If you do want to customize this behavior, specify an AddTaskCollectionResultHandler in the CustomBehaviors or additionalBehaviors collections.

Applies to