SocketAsyncEventArgs Construtores
Definição
Sobrecargas
| SocketAsyncEventArgs() |
Cria uma instância SocketAsyncEventArgs vazia.Creates an empty SocketAsyncEventArgs instance. |
| SocketAsyncEventArgs(Boolean) |
Inicializa o SocketAsyncEventArgs.Initializes the SocketAsyncEventArgs. |
SocketAsyncEventArgs()
Cria uma instância SocketAsyncEventArgs vazia.Creates an empty SocketAsyncEventArgs instance.
public:
SocketAsyncEventArgs();
public SocketAsyncEventArgs ();
Public Sub New ()
Exceções
Não há suporte para a plataforma.The platform is not supported.
Exemplos
O exemplo de código a seguir representa uma coleção de objetos reutilizáveis SocketAsyncEventArgs .The following code example represents a collection of reusable SocketAsyncEventArgs objects.
// Represents a collection of reusable SocketAsyncEventArgs objects.
class SocketAsyncEventArgsPool
{
Stack<SocketAsyncEventArgs> m_pool;
// Initializes the object pool to the specified size
//
// The "capacity" parameter is the maximum number of
// SocketAsyncEventArgs objects the pool can hold
public SocketAsyncEventArgsPool(int capacity)
{
m_pool = new Stack<SocketAsyncEventArgs>(capacity);
}
// Add a SocketAsyncEventArg instance to the pool
//
//The "item" parameter is the SocketAsyncEventArgs instance
// to add to the pool
public void Push(SocketAsyncEventArgs item)
{
if (item == null) { throw new ArgumentNullException("Items added to a SocketAsyncEventArgsPool cannot be null"); }
lock (m_pool)
{
m_pool.Push(item);
}
}
// Removes a SocketAsyncEventArgs instance from the pool
// and returns the object removed from the pool
public SocketAsyncEventArgs Pop()
{
lock (m_pool)
{
return m_pool.Pop();
}
}
// The number of SocketAsyncEventArgs instances in the pool
public int Count
{
get { return m_pool.Count; }
}
}
Comentários
Depois de chamar esse construtor, todas as propriedades terão seus valores padrão:After calling this constructor all properties will have their default values:
Referências de objeto serão nulasObject references will be null
As propriedades que retornam um inteiro retornarão zero.Properties that return an integer will return zero.
A LastOperation propriedade será igual a None .The LastOperation property will be equal to None.
A SendPacketsFlags propriedade será igual a TransmitFileOptions.UseDefaultWorkerThread , que especifica que nenhum sinalizador será usado.The SendPacketsFlags property will be equal to TransmitFileOptions.UseDefaultWorkerThread, which specifies no flags will be used.
A SocketFlags propriedade será igual a None .The SocketFlags property will be equal to None.
O chamador deve definir as propriedades apropriadas antes de passar o objeto para o método soquete assíncrono apropriado (xxxAsync).The caller must set the appropriate properties prior to passing the object to the appropriate asynchronous socket (xxxAsync) method.
Aplica-se a
SocketAsyncEventArgs(Boolean)
Inicializa o SocketAsyncEventArgs.Initializes the SocketAsyncEventArgs.
public:
SocketAsyncEventArgs(bool unsafeSuppressExecutionContextFlow);
public SocketAsyncEventArgs (bool unsafeSuppressExecutionContextFlow);
new System.Net.Sockets.SocketAsyncEventArgs : bool -> System.Net.Sockets.SocketAsyncEventArgs
Public Sub New (unsafeSuppressExecutionContextFlow As Boolean)
Parâmetros
- unsafeSuppressExecutionContextFlow
- Boolean
Indica se a captura e o fluxo do contexto de execução devem ser desabilitados.Whether to disable the capturing and flow of execution context. O fluxo do contexto de execução só deverá ser desabilitado se for tratado por camadas superiores.Execution context flow should only be disabled if it's handled by higher layers.