BlockingCollection<T>.TryAddToAny Método

Definição

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

Sobrecargas

TryAddToAny(BlockingCollection<T>[], T, Int32, CancellationToken)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

TryAddToAny(BlockingCollection<T>[], T, TimeSpan)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas, observando ao mesmo tempo o token de cancelamento especificado.Tries to add the specified item to any one of the specified BlockingCollection<T> instances while observing the specified cancellation token.

TryAddToAny(BlockingCollection<T>[], T, Int32)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

TryAddToAny(BlockingCollection<T>[], T)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

TryAddToAny(BlockingCollection<T>[], T, Int32, CancellationToken)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

public:
 static int TryAddToAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, T item, int millisecondsTimeout, System::Threading::CancellationToken cancellationToken);
public static int TryAddToAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken);
static member TryAddToAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T * int * System.Threading.CancellationToken -> int
Public Shared Function TryAddToAny (collections As BlockingCollection(Of T)(), item As T, millisecondsTimeout As Integer, cancellationToken As CancellationToken) As Integer

Parâmetros

collections
BlockingCollection<T>[]

A matriz de coleções.The array of collections.

item
T

O item a ser adicionado a uma das coleções.The item to be added to one of the collections.

millisecondsTimeout
Int32

O número de milissegundos para aguardar ou Infinite (- 1) para aguardar indefinidamente.The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

cancellationToken
CancellationToken

Um token de cancelamento a ser observado.A cancellation token to observe.

Retornos

Int32

O índice da coleção na matriz collections ao qual o item foi adicionado ou -1 caso o item não possa ser adicionado.The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceções

Se o padrão CancellationToken for cancelado.If the CancellationToken is canceled.

Pelo menos uma coleção subjacente não aceitou o item.At least one underlying collection didn't accept the item.

O argumento collections é nulo.The collections argument is null.

millisecondsTimeout é um número negativo diferente de -1, que representa um tempo limite infinito.millisecondsTimeout is a negative number other than -1, which represents an infinite time-out. - ou --or- A contagem de collections é maior que o tamanho máximo de 62 para STA e 63 para MTA.The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

O argumento collections é uma matriz de tamanho 0 ou contém um elemento nulo, ou pelo menos uma das coleções foi marcada como completa para adição.The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.

Pelo menos uma das instâncias de BlockingCollection<T> foi descartada.At least one of the BlockingCollection<T> instances has been disposed.

Aplica-se a

TryAddToAny(BlockingCollection<T>[], T, TimeSpan)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas, observando ao mesmo tempo o token de cancelamento especificado.Tries to add the specified item to any one of the specified BlockingCollection<T> instances while observing the specified cancellation token.

public:
 static int TryAddToAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, T item, TimeSpan timeout);
public static int TryAddToAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, T item, TimeSpan timeout);
static member TryAddToAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T * TimeSpan -> int
Public Shared Function TryAddToAny (collections As BlockingCollection(Of T)(), item As T, timeout As TimeSpan) As Integer

Parâmetros

collections
BlockingCollection<T>[]

A matriz de coleções.The array of collections.

item
T

O item a ser adicionado a uma das coleções.The item to be added to one of the collections.

timeout
TimeSpan

Um TimeSpan que representa o número de milissegundos para aguardar ou um TimeSpan que representa -1 milissegundos para aguardar indefinidamente.A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds to wait indefinitely.

Retornos

Int32

O índice da coleção na matriz collections ao qual o item foi adicionado ou -1 caso o item não possa ser adicionado.The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceções

Pelo menos uma das instâncias BlockingCollection<T> ou o CancellationTokenSource que criou cancellationToken foi descartado.At least one of the BlockingCollection<T> instances or the CancellationTokenSource that created cancellationToken has been disposed.

O argumento collections é nulo.The collections argument is null.

timeout é um número negativo diferente de -1 milissegundos, que representa um tempo limite infinito ou o tempo limite é maior que MaxValue.timeout is a negative number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than MaxValue.

- ou --or- A contagem de collections é maior que o tamanho máximo de 62 para STA e 63 para MTA.The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

O argumento collections é uma matriz de tamanho 0 ou contém um elemento nulo, ou pelo menos uma das coleções foi marcada como completa para adição.The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.

Pelo menos uma coleção subjacente não aceitou o item.At least one underlying collection didn't accept the item.

Comentários

Esse método pode retornar antecipadamente se o cancellationToken for cancelado antes do espaço disponível para a operação de adição.This method can return early if the cancellationToken is cancelled before space was available for the Add operation.

Aplica-se a

TryAddToAny(BlockingCollection<T>[], T, Int32)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

public:
 static int TryAddToAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, T item, int millisecondsTimeout);
public static int TryAddToAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, T item, int millisecondsTimeout);
static member TryAddToAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T * int -> int
Public Shared Function TryAddToAny (collections As BlockingCollection(Of T)(), item As T, millisecondsTimeout As Integer) As Integer

Parâmetros

collections
BlockingCollection<T>[]

A matriz de coleções.The array of collections.

item
T

O item a ser adicionado a uma das coleções.The item to be added to one of the collections.

millisecondsTimeout
Int32

O número de milissegundos para aguardar ou Infinite (- 1) para aguardar indefinidamente.The number of milliseconds to wait, or Infinite (-1) to wait indefinitely.

Retornos

Int32

O índice da coleção na matriz collections ao qual o item foi adicionado ou -1 caso o item não possa ser adicionado.The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceções

Pelo menos uma das instâncias de BlockingCollection<T> foi descartada.At least one of the BlockingCollection<T> instances has been disposed.

O argumento collections é nulo.The collections argument is null.

millisecondsTimeout é um número negativo diferente de -1, que representa um tempo limite infinito.millisecondsTimeout is a negative number other than -1, which represents an infinite time-out. - ou --or- A contagem de collections é maior que o tamanho máximo de 62 para STA e 63 para MTA.The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

O argumento collections é uma matriz de tamanho 0 ou contém um elemento nulo, ou pelo menos uma das coleções foi marcada como completa para adição.The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.

Pelo menos uma coleção subjacente não aceitou o item.At least one underlying collection didn't accept the item.

Aplica-se a

TryAddToAny(BlockingCollection<T>[], T)

Tenta adicionar o item especificado a qualquer uma das instâncias BlockingCollection<T> especificadas.Tries to add the specified item to any one of the specified BlockingCollection<T> instances.

public:
 static int TryAddToAny(cli::array <System::Collections::Concurrent::BlockingCollection<T> ^> ^ collections, T item);
public static int TryAddToAny (System.Collections.Concurrent.BlockingCollection<T>[] collections, T item);
static member TryAddToAny : System.Collections.Concurrent.BlockingCollection<'T>[] * 'T -> int
Public Shared Function TryAddToAny (collections As BlockingCollection(Of T)(), item As T) As Integer

Parâmetros

collections
BlockingCollection<T>[]

A matriz de coleções.The array of collections.

item
T

O item a ser adicionado a uma das coleções.The item to be added to one of the collections.

Retornos

Int32

O índice da coleção na matriz collections ao qual o item foi adicionado ou -1 caso o item não possa ser adicionado.The index of the collection in the collections array to which the item was added, or -1 if the item could not be added.

Exceções

Pelo menos uma das instâncias de BlockingCollection<T> foi descartada.At least one of the BlockingCollection<T> instances has been disposed.

O argumento collections é nulo.The collections argument is null.

A contagem de collections é maior que o tamanho máximo de 62 para STA e 63 para MTA.The count of collections is greater than the maximum size of 62 for STA and 63 for MTA.

O argumento collections é uma matriz de tamanho 0 ou contém um elemento nulo, ou pelo menos uma das coleções foi marcada como completa para adição.The collections argument is a 0-length array or contains a null element, or at least one of collections has been marked as complete for adding.

Pelo menos uma coleção subjacente não aceitou o item.At least one underlying collection didn't accept the item.

Aplica-se a