共用方式為


<lifetime> Element

Contains information about the lifetime of all client-activated objects serviced by this application. Specific lifetime control for individual objects can be set by overriding MarshalByRefObject.InitializeLifetimeService on your remote type.

<configuration>
   <system.runtime.remoting>
      <application>
         <lifetime>

<lifetime 
   leaseTime="leasetime"
   sponsorshipTimeout="sponsorshipTimeOut"
   renewOnCallTime="renewOnCallTime"
   leaseManagerPollTime="pollTime" 
/>

Optional Attributes

Attribute Description
leaseTime Specifies the lease time for the application. The default leaseTime is 5 minutes.
sponsorshipTimeout Specifies the time the lease manager waits for the sponsor to respond when notified that a lease has expired. If the sponsor does not respond in the specified time, the garbage collector disposes of the remote object. The default sponsorshipTimeout is 2 minutes.
renewOnCallTime Specifies the amount of time that the lease time is extended with every function call on the object. The default renewOnCallTime is 2 minutes.
leaseManagerPollTime Specifies the amount of time the lease manager sleeps after checking for expired leases. The default leaseManagerPollTime is 10 seconds.

Remarks

The <lifetime> element has four optional attributes. Valid values for each are a decimal and a time unit. Valid time units are D for days, H for hours, M for minutes, S for seconds, and MS for milliseconds. If no unit is specified, the default time unit is seconds. For example, "10" is interpreted as "10S".

Example

The following example sets all client-activated objects to a 5-minute lease time, a sponsorship time-out of 2 minutes, a renewal of 2 more minutes each time a method is called, and a lease manager poll time of 10 seconds.

<lifetime 
   leaseTime="5M" 
   sponsorshipTimeOut="2M" 
   renewOnCallTime="2M" 
   leaseManagerPollTime="10S"
/>

Requirements

Configuration Files: Application configuration file, machine configuration file (Machine.config)

See Also

Remoting Settings Schema | Activation | MarshalByRefObject.InitializeLifetimeService