简体   繁体   中英

What is the fastest and easiest way to communicate between 2 processes in C#?

From my main c# app, I start many slave process with Process.Start method. (on the same PC)

Just before starting those slave process, I serialize some data (I have serialized class) in XML files which are passed in the arguments of Process class.

In each slave process, those data are deserialized and a computation is done. A new serialization is done to XML in order to send result to the main process.

My apps works but the performance are very bad. The time of serialization/deserialization operation is too long because the size of each XML file is about 1,5 Mo...

I really need a high-performance for this simple communication between main app and slave process.

How can I easily modify my code to improve this performance ? Nb : in the future my main process will be in 64 bits and the slaves process in 32 bits.

I have heard that some apps allows to virtualize hard disk in RAM ? Does it exist ? Is it free ?

I have heard of WCF, Named Pipe, Memory Mapped, etc but I seems to be heavy to use ....?

Memory-mapped files (MMF) are the fastest method. The problem though, as you point, is in serialization rather than transfer itself. Serialization is necessary for any transport, even MMFs (except the simplest cases when you have simple data records which can be laid out sequentially in memory). XML is not fast - binary serialization of any kind would work much better.

Use SlimSerializer from here: https://github.com/aumcode/nfx/tree/master/Source/NFX/Serialization/Slim

hundreds of thousands of serialization transactions on a second on a single thread - that is for "typical Person" object (name, address , contact info, salary)

Also see this post about Glue

Glue is designed for "glue-ing" processes together very efficiently

Video

Another Video (In Russian)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM