Bagikan melalui


ServicePoint.ConnectionLimit Properti

Definisi

Mendapatkan atau mengatur jumlah maksimum koneksi yang diizinkan pada objek ini ServicePoint .

public:
 property int ConnectionLimit { int get(); void set(int value); };
public int ConnectionLimit { get; set; }
member this.ConnectionLimit : int with get, set
Public Property ConnectionLimit As Integer

Nilai Properti

Jumlah maksimum koneksi yang diizinkan pada objek ini ServicePoint .

Pengecualian

Batas koneksi sama dengan atau kurang dari 0.

Contoh

Contoh kode berikut menggunakan ConnectionLimit properti untuk memeriksa jumlah maksimum koneksi yang ServicePoint dapat dibuat objek ke Pengidentifikasi Sumber Daya Seragam (URI) yang ditentukan.

Console.WriteLine("ConnectionName = " + sp.ConnectionName);

// Display the maximum number of connections allowed on this
// ServicePoint instance.
Console.WriteLine("ConnectionLimit = " + sp.ConnectionLimit);

// Display the number of connections associated with this
// ServicePoint instance.
Console.WriteLine("CurrentConnections = " + sp.CurrentConnections);
Console.WriteLine(("ConnectionName = " + sp.ConnectionName))

' Display the maximum number of connections allowed on this 
' ServicePoint instance.
Console.WriteLine(("ConnectionLimit = " + sp.ConnectionLimit.ToString()))

' Display the number of connections associated with this 
' ServicePoint instance.
Console.WriteLine(("CurrentConnections = " + sp.CurrentConnections.ToString()))

Keterangan

Hati

WebRequest, , HttpWebRequestServicePoint, dan WebClient usang, dan Anda tidak boleh menggunakannya untuk pengembangan baru. Gunakan HttpClient sebagai gantinya.

Properti ConnectionLimit mengatur jumlah maksimum koneksi yang ServicePoint dapat dilakukan objek ke sumber daya Internet. Nilai ConnectionLimit properti diatur ke nilai ServicePointManager.DefaultConnectionLimit properti saat ServicePoint objek dibuat; perubahan DefaultConnectionLimit berikutnya tidak berpengaruh pada objek yang ada ServicePoint .

Batas koneksi tidak berlaku untuk koneksi yang diproksi atau terowongan proksi.

Nota

Sejak .NET 9, properti ini memetakan ke SocketsHttpHandler.MaxConnectionsPerServer. Namun, handler tidak digunakan kembali di antara permintaan sehingga tidak memiliki dampak yang berarti.

Berlaku untuk

Lihat juga