0

I am trying to create 2 programs that have common code. I need one to add or delete data to/from an array that can be read by the other. Right now I have created a dll that has the class, but my problem is that I don't know how to properly instantiate it so that both programs will be using the same data. Both processes would not be running at the same time.

  • Do you mean two separate processes (two *.exe files) should use the same piece of data (Array)? – Dmitry Harnitski Jun 10 '12 at 02:37
  • Yes, I want one process to add to the array and the other to be able to read it. – Bryan Everson Jun 10 '12 at 02:51
  • Have you considered using a WCF named pipe for interprocess communication? – Jeff Winn Jun 10 '12 at 02:55
  • I have not because I don't know what that is, thanks for the idea. I'm fairly new to programming so I wasn't even sure if a dll is what I would use for this situation. – Bryan Everson Jun 10 '12 at 03:00
  • DLLs are good for creating reusable objects both processes can consume, but getting both processes to essentially talk to each other can be quite difficult. – Jeff Winn Jun 10 '12 at 03:06
  • @JeffWinn, I was wondering if it mattered that the processes would not be running at the same time, one would be an editing tool to modify the array that the other would use at a later time. – Bryan Everson Jun 10 '12 at 03:36
  • How is this data going to be used? Flat file/db??? Basically, is there ever a need for the data to persist? – Jared Jun 10 '12 at 03:44
  • Yes, a named pipe would require both processses to be active at the same time. Ah, I see you modified your question to make a note of it, good. – Jeff Winn Jun 11 '12 at 14:32

2 Answers2

1

One fundamental "rule" is that each process is running in it's "own little world". From the program's perspective, it has the entire computer (and all computer resources, like memory) to itself. It has no direct knowledge of any other process, and it cannot "just share" data.

Take a brief look at this thread:

You have many, many choices for "interprocess communications". Including COM/ActiveX, .Net remoting, named pipes, shared memory, WCF, etc etc.

Just to give you some idea where to start, I encourage you to look at "sockets". For example:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
1

You could use Memory Mapped Files but you could also look at the many other ways for two processes to communicate such as by using MSMQ, Named Pipes ...

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133