By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,046 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Shared memory - how to implement in .NET 2.0/3.0

P: n/a
I am coding a dozen "background" realtime apps for factory automation in .NET
2.0.

The apps need to share a common memory as there are lots of variables to be
shared (and synchronized of course).
I need distinct apps for reasons like user interaction/access rights, error
compartments, and because the size of the code, access to various ports, ...

In the end the apps should run as Windows Service(s).

How can I implement shared memory using .NET 2.0/3.0?

thanks herbert
Nov 26 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hello herbert,

hThe apps need to share a common memory as there are lots of variables
hto be shared (and synchronized of course).

Shared among who? How much your app is distributed?
For example you can use MMF http://groups.google.com/groups/sear...y+mapped+file&
but I'm not sure that is the right thing for u

hI need distinct apps for reasons like user interaction/access rights,
herror compartments, and because the size of the code, access to various
hports, ...

So, u need the set of control services? how shared memory will help u here?

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #2

P: n/a
Thank you, Michael.

this looks like a big stumbling block for me. I do .NET since 2002, yet it
is my only language so I don't have any C/C++/Win32 knowledge. Is there an
intro article about memory mapped files?

I did other operating systems before where data structures could be compiled
into .dlls, loaded into memory and accessed by all apps which were linked
against this .dll

Basically my IO apps read hundreds of relais, opto couplers and the like and
need to offer this knowledge to other apps which draw conclusions, do
emergency halts, and some other serious stuff.

I do not want to send all the data to all the possible recipients using
network protocols, and I do not want to duplicate data inside a single
computer.

It also needs remote events from server to clients, which I do using .NET
remoting while waiting for Indigo to pass the bleeding edge. (aka books and
samples about WCF).

best regards herbert
Nov 26 '06 #3

P: n/a
Hello herbert,

hthis looks like a big stumbling block for me. I do .NET since 2002,
hyet it is my only language so I don't have any C/C++/Win32 knowledge.
hIs there an intro article about memory mapped files?

See the MSDN for more details about MMF

So, probably you need Singleton class
hI do not want to send all the data to all the possible recipients
husing network protocols, and I do not want to duplicate data inside a
hsingle computer.

How are u going to communicate with you class if u don't want to send data
to recipients?

hIt also needs remote events from server to clients, which I do using
h.NET remoting while waiting for Indigo to pass the bleeding edge.
h(aka books and samples about WCF).
Thus just create Singleton service which will maintain your shared data and
choose appropriate IPC way for communications

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Nov 26 '06 #4

P: n/a
Its not too hard there are lots of examples around. Sharing data
amongst many applications via shared memory is reasonably common thing
to do. The way we did it was to have a dll written in unmanaged C++.
With .Net 2.0 it was real easy to use the dll in managed C++. In our
case .Net is only one development environment to use the shared memory.
We also use VB6, C++, Labview, and Java. Our shared memory can also be
shared to other machines so applications can be distributed. It uses an
replication scheme to manage this. Bottom line is though you will
probably have to learn C++ and Win32 APIs to do this. The really hard
part though is doing things in a very concurrency safe scheme. Unless
you are really familiar with Mutexes and NT events you might have a very
difficult time to get it safe. Also creating a shared memory manager
with compaction is also tricky especially if any of your applications
are soft real time like ours. I have a solid code base for dealing with
all this and would live to open source it but can't because i used
company tools to make it. Someday i will start from scratch on my own
machine on my own time to create a new code base so i can open source
it. That may be a while though.

Hope this helps
Leon Lambert

Michael Nemtsev wrote:
Hello herbert,

hThe apps need to share a common memory as there are lots of variables
hto be shared (and synchronized of course).

Shared among who? How much your app is distributed?
For example you can use MMF
http://groups.google.com/groups/sear...y+mapped+file&
but I'm not sure that is the right thing for u

hI need distinct apps for reasons like user interaction/access rights,
herror compartments, and because the size of the code, access to various
hports, ...

So, u need the set of control services? how shared memory will help u here?

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche

Nov 27 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.