Transferring objects between two independent applications (C #)

Is it possible to transfer an object from one application to another (in C #)?

I work with CAD API. Initializing this API takes a few seconds (10-15). It would be nice if I could only initialize the object once in App1 and call it from App2 whenever I need it.

Any ideas? Thanks!

+4
source share
3 answers

You can do this by serializing your object and using any form of Interprocess Communication to transfer data, and then deserialize it at the other end.

The Windows Communication Foundation is specifically suited for this type of scenario and handles most of the plumbing for you.

+6
source

While Reed's suggestion is great, perhaps this is not the only opportunity worth considering. 10-15 seconds initialization for quite a long time. This may be the initialization of some rather large complex data structures, which can take quite a while to serialize and deserialize. If so, it might be worth considering another possibility, such as creating a COM server (or DCOM) outside the process, which acts as an interface for the CAD API, and then let both App1 and App2 work with this server in one place . This would mean marching and canceling all the data that you send / receive from the CAD API, but depending on how much data is involved and (in particular) how often you will need to switch from the fact that it is used by App1 vs. App2, it can still have less overhead.

+1
source

In my opinion, it is even easier to use shared memory. This is a common interprocess communication mechanism under Windows. You can take a look at the related CodeProject article .

+1
source

Source: https://habr.com/ru/post/1306298/


All Articles