/// <summary> /// Initializes a new instance of the <see cref="InterprocessMemoryMappedFile"/> class. /// </summary> /// <param name="memoryMappedFile">An instance of a memory mapped file</param> /// <param name="fileWaitHandle">A manual reset EventWaitHandle that is to be used to signal file changes</param> /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param> /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param> /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param> public InterprocessMemoryMappedFile(MemoryMappedFile memoryMappedFile, EventWaitHandle fileWaitHandle, Int64 maxFileSize, IInterprocessReadWriteLock readWriteLock, Boolean disposeLock) { _readWriteLock = readWriteLock ?? throw new ArgumentNullException(nameof(readWriteLock)); _memoryMappedFile = memoryMappedFile ?? throw new ArgumentNullException(nameof(memoryMappedFile)); _fileWaitHandle = fileWaitHandle ?? throw new ArgumentNullException(nameof(fileWaitHandle)); _disposeLock = disposeLock; MaxFileSize = maxFileSize; _disposeWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); _fileWatcherTask = Task.Run(FileWatcher); }
/// <summary> /// Initializes a new instance of the <see cref="InterprocessMemoryMappedFile"/> class. /// </summary> /// <param name="name">A system wide unique name, the name will have a prefix appended before use</param> /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param> /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param> /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param> public InterprocessMemoryMappedFile(String name, Int64 maxFileSize, IInterprocessReadWriteLock readWriteLock, Boolean disposeLock) : this(CreateOrOpenMemoryMappedFile(name, maxFileSize), CreateEventWaitHandle(name), maxFileSize, readWriteLock, disposeLock) { }