ArcGIS Pro 2.7 API Reference Guide
SetExpirationMaxCount Method (StreamLayer)
Example 

ArcGIS.Desktop.Mapping Namespace > StreamLayer Class : SetExpirationMaxCount Method
The values indicating how many features will be stored at any given time.
Gets the expiration maximum feature count. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public void SetExpirationMaxCount( 
   ulong expirationMaxCount
)
Public Sub SetExpirationMaxCount( _
   ByVal expirationMaxCount As ULong _
) 

Parameters

expirationMaxCount
The values indicating how many features will be stored at any given time.
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Stream service data connection is null.
Remarks
SetExpirationMethod must be set to ArcGIS.Core.CIM.FeatureExpirationMethod.MaximumFeatureCount or the maximum feature count is ignored. When FeatureLayer.IsTrackAware is true, ExpirationMaxCount represents the maximum number of features that will be stored per track. Otherwise, it represents the maximum number of features that will be stored period. The stream layer uses a FIFO method - the first observation in is the first one to be removed and so on. To prevent any features from being removed, set ExpirationMaxCount to 0.

When a stream layer is track-aware, use FeatureLayer.SetPreviousObservationsCount to set how many will be displayed on the map. Whereas SetExpirationMaxCount defines how many previous observation will be stored in memory.

Example
Setting how many previous observations for each track will be stored in the memory.
//Must be on QueuedTask
//Set Expiration Method and Max Expiration Count
if (streamLayer.GetExpirationMethod() != FeatureExpirationMethod.MaximumFeatureCount)
  streamLayer.SetExpirationMethod(FeatureExpirationMethod.MaximumFeatureCount);
streamLayer.SetExpirationMaxCount(15);
//FYI
if (streamLayer.IsTrackAware)
{
  //MaxCount is per track! otherwise for the entire layer
}
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

StreamLayer Class
StreamLayer Members