Inter-process communication between Managed Process
There are certain cases, where the developer needs to pass data to another process running on the same system. One of the efficient ways of handling the situation in a Win32 application is using memory mapped files. Mapping between a file and memory allows multiple applications to read and write in the file at the same time. Starting from .NET 4.0, Managed applications can use the memory mapped file functionality as the traditional Win32 application does.
Memory mapped files can be categorized into two types.
1. Physical memory mapped file.
2. Virtual memory mapped file.
Physical Memory Mapped File
Physical memory mapped files are also referred as Persisted memory mapped files. This category of memory mapped file is always associated with a physical file in your hard disk. Very suitable for applications which need to work with huge data files. Once the last process is finished working with the physical memory mapped file, the contents of the file is written back to the source file on the hard disk.
Virtual Memory Mapped File
This category is also known as Non-Persisted memory mapped file. As the name means indicates, it is not associated with a source file on hard disk. It is very effective for run time data communication between two processes.
Let's have a closer look at programming the inter-process communication using the memory mapped files.
As any other files programing you do, the first step is to create the memory mapped file. System.IO.MemoryMappedFile class provides many different static functions to create the memory mapped file.
MemoryMappedFile.CreateNew static function takes 2 arguments. The first one is a string parameter specifying a unique name for the file. This name will uniquely identify the memory mapped file across the processes. The second parameter is a long data type, used to specify the maximum number of bytes that can be stored by the memory mapped file. While creating the file you can also specify the access mode for restricting the access to that file.
The following table lists the entire access mode supported.
Enumerator: MemoryMappedFileAccess

SubashPosted Sep 19, 2016, 8:12 AM
Useful share
Manish SinghPosted Jan 10, 2012, 11:19 AM
Really helpful and useful article
Alok PandeyPosted Jan 9, 2012, 11:15 PM
Very helpful article. Thanks for sharing.
Sonakshi SinghPosted Jan 9, 2012, 11:12 PM
Very Innovative...really.
Daisy KrausePosted Jan 9, 2012, 11:02 PM
Its a very good article for those who want to implement interprocess communication. Thanks for sharing.
Arjun PanwarPosted Jan 9, 2012, 6:23 PM
Really very nice article
Deepak DwijPosted Jan 9, 2012, 6:22 PM
Nicely explained !!!!!!!!!!!!!
Vikas MishraPosted Jan 9, 2012, 5:12 PM
It's a very fresh example..thanks for sharing....
Akash AhlawatPosted Jan 9, 2012, 5:08 PM
Perfect example..I'm happy that there are still developers who bring some new examples to ASP.NET community
Sam HobbsPosted Jan 9, 2012, 4:38 PM
I know that memory-mapped files are very useful. They provide a very efficient way to share large amounts of data among processes. This article will help many people. I have one question; are you sure that Virtual Memory Mapped Files have no physical disk space associted with them? I thought that they are backed by the system paging file.