SocketAsyncEventArgs Constructeurs

Définition

Surcharges

SocketAsyncEventArgs()

Crée une instance SocketAsyncEventArgs vide.

SocketAsyncEventArgs(Boolean)

Initialise la SocketAsyncEventArgs.

SocketAsyncEventArgs()

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

Crée une instance SocketAsyncEventArgs vide.

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

Exceptions

La plateforme n'est pas prise en charge.

Exemples

L’exemple de code suivant représente une collection d’objets réutilisables 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; }
    }
}

Remarques

Après avoir appelé ce constructeur, toutes les propriétés ont leurs valeurs par défaut :

L’appelant doit définir les propriétés appropriées avant de passer l’objet à la méthode de socket asynchrone (xxxAsync) appropriée.

S’applique à

SocketAsyncEventArgs(Boolean)

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

Initialise la 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)

Paramètres

unsafeSuppressExecutionContextFlow
Boolean

Indique s’il faut désactiver la capture et le flux du contexte d’exécution. Le flux du contexte d’exécution doit être désactivé uniquement s’il est géré par des couches supérieures.

S’applique à