Class FileToTimeShotMapping
Provides mapping between files and time shot data with caching capabilities. This class manages the loading and caching of time shot data from measurement files.
public class FileToTimeShotMapping
- Inheritance
-
FileToTimeShotMapping
- Inherited Members
- Extension Methods
Properties
LineReaded
Gets or sets the callback action that is invoked when a line is read from a file. This can be used to track progress during file loading operations.
public Action<int> LineReaded { get; set; }
Property Value
Remarks
The parameter passed to the action is the current line number being read. This is useful for implementing progress indicators or logging.
Methods
CallTimeShotByFile(string, CancellationToken?)
Gets time shot data from a file, using cache if available. If the data is not in the cache, reads the file and caches the results.
public List<ITimeShot> CallTimeShotByFile(string file, CancellationToken? cancellationToken = null)
Parameters
file
stringThe file path to read time shot data from.
cancellationToken
CancellationToken?Optional cancellation token to cancel the operation.
Returns
- List<ITimeShot>
A list of time shots from the file. The results are cached for subsequent calls. Returns null if the file cannot be read or contains invalid data.
Remarks
This method is thread-safe and ensures each file is only read once, even with concurrent access. The cached data is shared between all callers to improve performance.
Clear()
Clears the file to time shot mapping cache. This removes all cached data and frees up memory.
public void Clear()
Remarks
Call this method when:
- The cached data is no longer needed
- You need to force a reload of data from files
- You need to free up memory