public PersistedEventsStorage(PersistedOptions options) { cache = new JsonDataCache<PersistedEvent>(options); this.options = options; streamSource = options.StreamSource; file = streamSource.OpenReadWrite(dataPath); ReadAllFromDisk(); binaryWriter = new BinaryWriter(file, Encoding.UTF8, leaveOpen: true); writerTask = Task.Factory.StartNew(() => { try { WriteToDisk(); } catch (Exception e) { corruptingException = e; } }); }
public PersistedEventsStorage(PersistedOptions options) { cache = new JsonDataCache <PersistedEvent>(options); this.options = options; streamSource = options.StreamSource; file = streamSource.OpenReadWrite(dataPath); ReadAllFromDisk(); binaryWriter = new BinaryWriter(file, Encoding.UTF8, leaveOpen: true); writerTask = Task.Factory.StartNew(() => { try { WriteToDisk(); } catch (Exception e) { corruptingException = e; } }); }