I have two different windows applications (two different people writing the code). One is Written in C++ and another one is in C#. I need some way how to share data in RAM between them. One must writes data and another one just reads the written data. What should I use to make it most effective and fast? Thanks.
If the two programs are running on the same machine, yes, you can have them share memory. You can do this with shared memory or memory-mapping the same file.
The user just writes data to the process memory, and the operating systems dumps the data to the file. When two processes map the same file in memory, the memory that one process writes is seen by another process, so memory mapped files can be used as an interprocess communication mechanism.
In computer programming, shared memory is a method by which program processes can exchange data more quickly than by reading and writing using the regular operating system services. For example, a client process may have data to pass to a server process that the server process is to modify and return to the client.
The SharedMemory library provides a set of C# classes that utilise a memory-mapped file for fast low-level inter-process communication (IPC) - specifically for sharing data between processes. * an implementation of a shared memory buffer for read/write.
You can use Memory Mapped Files.
Here is an article describing how to use them.
You can use Named Pipes.
A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously.
Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With