Share via


SocketAsyncEventArgs Oluşturucular

Tanım

Aşırı Yüklemeler

SocketAsyncEventArgs()

Boş SocketAsyncEventArgs bir örnek oluşturur.

SocketAsyncEventArgs(Boolean)

öğesini SocketAsyncEventArgsbaşlatır.

SocketAsyncEventArgs()

Kaynak:
SocketAsyncEventArgs.cs
Kaynak:
SocketAsyncEventArgs.cs
Kaynak:
SocketAsyncEventArgs.cs

Boş SocketAsyncEventArgs bir örnek oluşturur.

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

Özel durumlar

Platform desteklenmiyor.

Örnekler

Aşağıdaki kod örneği, yeniden kullanılabilir SocketAsyncEventArgs nesneler koleksiyonunu temsil eder.

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

Açıklamalar

Bu oluşturucu çağrıldıktan sonra tüm özelliklerin varsayılan değerleri olacaktır:

Çağıranın, nesneyi uygun zaman uyumsuz yuva (xxxAsync) yöntemine geçirmeden önce uygun özellikleri ayarlaması gerekir.

Şunlara uygulanır

SocketAsyncEventArgs(Boolean)

Kaynak:
SocketAsyncEventArgs.cs
Kaynak:
SocketAsyncEventArgs.cs
Kaynak:
SocketAsyncEventArgs.cs

öğesini SocketAsyncEventArgsbaşlatır.

public:
 SocketAsyncEventArgs(bool unsafeSuppressExecutionContextFlow);
public SocketAsyncEventArgs (bool unsafeSuppressExecutionContextFlow);
new System.Net.Sockets.SocketAsyncEventArgs : bool -> System.Net.Sockets.SocketAsyncEventArgs
Public Sub New (unsafeSuppressExecutionContextFlow As Boolean)

Parametreler

unsafeSuppressExecutionContextFlow
Boolean

Yürütme bağlamının yakalanmasını ve akışını devre dışı bırakılıp devre dışı bırakılmayacağı. Yürütme bağlamı akışı yalnızca daha yüksek katmanlar tarafından işlenirse devre dışı bırakılmalıdır.

Şunlara uygulanır