0

Process A and B both simultaneously open some data file and edit it's several data chunks. Each process uses FileStream and its Lock() and Unlock() methods. Thus, at the same time, one and the same piece of data can be edited only by process A or В but not by both simultaneously.

Is it possible to get the notification for A process when B process edited the file with detailed info about the position and length of the edited data chunk?

Some mechanism keeps track of the locking and unlocking. Perhaps the same mechanism can provide the information that interests me. I do not claim this, but I hope for such an opportunity is existing.

Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
  • 1
    Related, maybe duplicated of https://stackoverflow.com/questions/528652/what-is-the-simplest-method-of-inter-process-communication-between-2-c-sharp-pro – Cleptus Apr 18 '18 at 13:12
  • @bradbury9 no, my question is about other. I know how to send the data from one process to another. For example application **B** can be written not by me. But I still want to get such info. – Andrey Bushman Apr 18 '18 at 13:15
  • Some mechanism keeps track of the locking and unlocking. Perhaps the same mechanism can provide the information that interests me. I do not claim this, but I hope for such an opportunity is existing. – Andrey Bushman Apr 18 '18 at 13:18
  • "Some mechanism keeps track of the lock and its removal". Looks like `FileSystemWatcher` but if the FileStream is still open, I would go to the inter process communication and notify A that the lock ended. – Cleptus Apr 18 '18 at 13:20
  • @bradbury9 I know about it. But it notifies about the file editing without detailed info about what its chunk was edited. – Andrey Bushman Apr 18 '18 at 13:21
  • Just inter comm and write in the message the filename, the offset, and the size of data written/modified – Cleptus Apr 18 '18 at 13:23
  • @bradbury9 what is *inter comm*? – Andrey Bushman Apr 18 '18 at 13:30
  • Is it possible for you to use a [Memory-Mapped File](https://learn.microsoft.com/en-us/dotnet/standard/io/memory-mapped-files) in your context? It might also help a lot in concurrent read/write operations across processes. – Jimi Apr 18 '18 at 14:06

0 Answers0