SocketAsyncEventArgs Konstruktorer
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Överlagringar
| Name | Description |
|---|---|
| SocketAsyncEventArgs() |
Skapar en tom SocketAsyncEventArgs instans. |
| SocketAsyncEventArgs(Boolean) |
Initierar SocketAsyncEventArgs. |
SocketAsyncEventArgs()
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
Skapar en tom SocketAsyncEventArgs instans.
public:
SocketAsyncEventArgs();
public SocketAsyncEventArgs();
Public Sub New ()
Undantag
Plattformen stöds inte.
Exempel
Följande kodexempel representerar en samling återanvändbara SocketAsyncEventArgs objekt.
// 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; }
}
}
Kommentarer
När du har anropat den här konstruktorn har alla egenskaper sina standardvärden:
Objektreferenser är null
Egenskaper som returnerar ett heltal returnerar noll.
Egenskapen LastOperation är lika med None.
Egenskapen SendPacketsFlags är lika med , som anger att TransmitFileOptions.UseDefaultWorkerThreadinga flaggor ska användas.
Egenskapen SocketFlags är lika med None.
Anroparen måste ange lämpliga egenskaper innan objektet skickas till lämplig asynkron socketmetod (xxxAsync).
Gäller för
SocketAsyncEventArgs(Boolean)
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
- Källa:
- SocketAsyncEventArgs.cs
Initierar 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)
Parametrar
- unsafeSuppressExecutionContextFlow
- Boolean
Om du vill inaktivera infångnings- och flödeskontexten för körning. Körningskontextflöde bör endast inaktiveras om det hanteras av högre lager.