c# - How can I generate notifications that data written via a FileStream is on the disk? -
i read file after have been notified amount of data has been written via thread.
intial attempt create reactive subject in writer class calls onnext after write binarywriter composed with. binarywriter uses filestream.
this not seem work though. assuming i'm not guaranteed write has been flushed.
i'd rather not manually call flush. there existing way this?
at broader level, you're asking communications between threads. there couple of ways handle depending upon preferences , environment.
if haven't already, on posix threading here , here. pay attention sections discussing conditional variables or semaphores.
the .net framework has system threading library that's worth looking over. in particular, has both semaphore , monitor class. 1 or other may solution need in case.
finally, consider inotifypropertychanged interface , / or events. in context, it's alternate route signaling progress reader.
in general, i'd recommend having writer thread throw event changed notification or raise semaphore after writing x bytes. there, reader either catch event or watch semaphore , act accordingly.
i suspect monitor class won't useful since locking prevent simultaneous access file.
Comments
Post a Comment