need a way

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

I am looking for a way to have an application that is running in the
background serve data to other applications that only live for short periods
of time.

MainA runs all the time. It reads data from a disk(s) and loads it into some
type of memory, pipe or mailbox.

MainB then runs and has the ability to access the data MainA put in the
queue.

MainC then tells MainA to refresh the queue.

MainB then runs and accesses the new data.

Is this possible?

Am I missing something simple?
 
Hi !

You need two things. First is a shared memory section that is accessible by
many processes. Being accessible by multiple processes means that many
'applications' can access it. In Windows terms, each application that is
executed runs as a process. So, this type of data exchange is called
Interprocess Communication or IPC. More on this later.

The second thing you need is some sort of a messaging system. The most
efficient way, in Windows, is of course Windows Messaging (WM_). This means
that your MainA has a single thread, with one window object. It can respond
to a message called WM_CUSTOM_REFRESH_DATA, for example, and if this message
is not posted, the thread sleeps.

MainB uses the shared memory access to get data from the shared memory
section. This is quite trivial, see MSDN for CSharedFile if you're using
MFC. If not, then a named pipe is the solution.

MainC is responsible for sending the WM_CUSTOM_REFRESH_DATA to MainA. Note
that using Windows Messaging requires the applications to have a window that
will receive the data. Invisible, 0-sized window objects are a very
effective way and consume only minimal amount of resources.

So, you're not missing anything, it's just about doing it.

-Antti Keskinen
 
Great. I figured there was a way with IPC, just wasn't sure where to start.
Now the last question,,, The shared memory system I am going to build needs
to work between two different types of applications. MainA and MainC can be
MFC VC++ apps. But I need to access the data through a mex file,, in others
words MainB will be a MEX file running from Matlab. So it won't be MFC or
even windows api for that matter.

Any ideas?

I now have something to do this weekend!

Thanks
 
bill said:
Great. I figured there was a way with IPC, just wasn't sure where to
start. Now the last question,,, The shared memory system I am going
to build needs to work between two different types of applications.
MainA and MainC can be MFC VC++ apps. But I need to access the data
through a mex file,, in others words MainB will be a MEX file running
from Matlab. So it won't be MFC or even windows api for that matter.

Any ideas?

According to what I could find in a quick search of google, MEX files are
simply functions written in C that conform to a MATLAB imposed external API.

Within that function you can do anything you want, including use MFC or
access parts of the Win32 API, including your shared section and
synchronization mechanisms..

The compiled MEX file produces a DLL that's loaded by MATLAB.

-cd
 
Back
Top