Share via


ServicePoint.MaxIdleTime Propriété

Définition

Obtient ou définit la durée pendant laquelle une connexion associée à l'objet ServicePoint peut rester inactive avant la fermeture de la connexion.

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

Valeur de propriété

Durée, en millisecondes, pendant laquelle une connexion associée à l'objet ServicePoint peut rester inactive avant d'être fermée et réutilisée pour une autre connexion.

Exceptions

MaxIdleTime est défini sur inférieur Infinite ou supérieur à Int32.MaxValue.

Exemples

L’exemple de code suivant utilise la MaxIdleTime propriété pour définir et récupérer le temps d’inactivité ServicePoint .

// Display the date and time that the ServicePoint was last 
// connected to a host.
Console::WriteLine( "IdleSince = {0}", sp->IdleSince );

// Display the maximum length of time that the ServicePoint instance  
// is allowed to maintain an idle connection to an Internet  
// resource before it is recycled for use in another connection.
Console::WriteLine( "MaxIdleTime = {0}", sp->MaxIdleTime );
// Display the date and time that the ServicePoint was last
// connected to a host.
Console.WriteLine("IdleSince = " + sp.IdleSince.ToString());

// Display the maximum length of time that the ServicePoint instance
// is allowed to maintain an idle connection to an Internet
// resource before it is recycled for use in another connection.
Console.WriteLine("MaxIdleTime = " + sp.MaxIdleTime);
' Display the date and time that the ServicePoint was last 
' connected to a host.
Console.WriteLine(("IdleSince = " + sp.IdleSince.ToString()))


' Display the maximum length of time that the ServicePoint instance 
' is allowed to maintain an idle connection to an Internet  
' resource before it is recycled for use in another connection.
Console.WriteLine(("MaxIdleTime = " + sp.MaxIdleTime.ToString()))

Remarques

Vous pouvez définir sur MaxIdleTimeTimeout.Infinite pour indiquer qu’une connexion associée à l’objet ServicePoint ne doit jamais expirer.

La valeur par défaut de la MaxIdleTime propriété est la valeur de la ServicePointManager.MaxServicePointIdleTime propriété lors de la création de l’objet ServicePoint . Les modifications suivantes apportées à la MaxServicePointIdleTime propriété n’ont aucun effet sur les objets existants ServicePoint .

Lorsque le MaxIdleTime pour une connexion associée à un ServicePoint est dépassé, la connexion reste ouverte jusqu’à ce que l’application tente d’utiliser la connexion. À ce moment-là, l’infrastructure ferme la connexion et crée une nouvelle connexion à l’hôte distant.

S’applique à