Messaging through memory-mapped files in .NET C#
December 11, 2016 1 Comment
We saw in this and this posts how to use memory-mapped files to map an existing file to a memory location that multiple processes had access to on the same machine.
The same key objects, i.e. MemoryMappedFile and MemoryMappedViewAccessor can be used for interprocess messaging purposes. The following code shows how a “server” can create a new shared file mapped to memory. Here we use the CreateNew method for this purpose and give the file a mapping name. Note that this is only an in-memory file, it won’t be saved on disk: