Bagikan melalui


ServicePointManager.MaxServicePointIdleTime Properti

Definisi

Mendapatkan atau mengatur waktu ServicePoint menganggur maksimum objek.

public:
 static property int MaxServicePointIdleTime { int get(); void set(int value); };
public static int MaxServicePointIdleTime { get; set; }
static member MaxServicePointIdleTime : int with get, set
Public Shared Property MaxServicePointIdleTime As Integer

Nilai Properti

Waktu menganggur maksimum, dalam milidetik, dari objek ServicePoint . Nilai defaultnya adalah 100.000 milidetik (100 detik).

Pengecualian

Contoh

Contoh kode berikut mengatur properti ini.

// Set the maximum number of ServicePoint instances to 
// maintain. If a ServicePoint instance for that host already 
// exists when your application requests a connection to
// an Internet resource, the ServicePointManager object
// returns this existing ServicePoint instance. If none exists 
// for that host, it creates a new ServicePoint instance.
ServicePointManager::MaxServicePoints = 4;

// Set the maximum idle time of a ServicePoint instance to 10 seconds.
// After the idle time expires, the ServicePoint object is eligible for
// garbage collection and cannot be used by the ServicePointManager.
ServicePointManager::MaxServicePointIdleTime = 10000;
// Set the maximum number of ServicePoint instances to
// maintain. If a ServicePoint instance for that host already
// exists when your application requests a connection to
// an Internet resource, the ServicePointManager object
// returns this existing ServicePoint instance. If none exists
// for that host, it creates a new ServicePoint instance.
ServicePointManager.MaxServicePoints = 4;

// Set the maximum idle time of a ServicePoint instance to 10 seconds.
// After the idle time expires, the ServicePoint object is eligible for
// garbage collection and cannot be used by the ServicePointManager object.
ServicePointManager.MaxServicePointIdleTime = 10000;
' Set the maximum number of ServicePoint instances to maintain.
' Note that, if a ServicePoint instance for that host already 
' exists when your application requests a connection to
' an Internet resource, the ServicePointManager object
' returns this existing ServicePoint. If none exists 
' for that host, it creates a new ServicePoint instance.
ServicePointManager.MaxServicePoints = 4

' Set the maximum idle time of a ServicePoint instance to 10 seconds.
' After the idle time expires, the ServicePoint object is eligible for
' garbage collection and cannot be used by the ServicePointManager.
ServicePointManager.MaxServicePointIdleTime = 10000

Keterangan

Properti MaxServicePointIdleTime mengatur waktu menganggur maksimum yang ServicePointManager ditetapkan objek ke MaxIdleTime properti saat membuat ServicePoint objek. Perubahan pada nilai ini hanya ServicePoint memengaruhi objek yang diinisialisasi setelah nilai diubah.

ServicePoint Setelah objek diam selama waktu yang ditentukan dalam MaxIdleTime, objek memenuhi syarat untuk pengumpulan sampah. Objek ServicePoint menganggur ketika daftar koneksi yang terkait dengan ServicePoint objek kosong.

Berlaku untuk

Lihat juga