SocketAsyncEventArgs Constructores

Definición

Sobrecargas

SocketAsyncEventArgs()

Crea una instancia SocketAsyncEventArgs vacía.

SocketAsyncEventArgs(Boolean)

Inicializa el SocketAsyncEventArgs.

SocketAsyncEventArgs()

Source:
SocketAsyncEventArgs.cs
Source:
SocketAsyncEventArgs.cs
Source:
SocketAsyncEventArgs.cs

Crea una instancia SocketAsyncEventArgs vacía.

public:
 SocketAsyncEventArgs();
public SocketAsyncEventArgs ();
Public Sub New ()

Excepciones

No se admite la plataforma.

Ejemplos

En el ejemplo de código siguiente se representa una colección de objetos reutilizables SocketAsyncEventArgs .

// 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; }
    }
}

Comentarios

Después de llamar a este constructor, todas las propiedades tendrán sus valores predeterminados:

El autor de la llamada debe establecer las propiedades adecuadas antes de pasar el objeto al método de socket asincrónico adecuado (xxxAsync).

Se aplica a

SocketAsyncEventArgs(Boolean)

Source:
SocketAsyncEventArgs.cs
Source:
SocketAsyncEventArgs.cs
Source:
SocketAsyncEventArgs.cs

Inicializa el 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

Si se deshabilita la captura y el flujo del contexto de ejecución. El flujo del contexto de ejecución solo debe deshabilitarse si está controlado por niveles superiores.

Se aplica a