Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2005

Tip: Looking for answers? Try searching our database.

need a way

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bill - 14 Feb 2005 22:42 GMT
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?
Antti Keskinen - 15 Feb 2005 07:49 GMT
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

>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
[quoted text clipped - 13 lines]
>
> Am I missing something simple?
bill - 15 Feb 2005 11:56 GMT
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

> Hi !
>
[quoted text clipped - 40 lines]
>>
>> Am I missing something simple?
Carl Daniel [VC++ MVP] - 15 Feb 2005 15:08 GMT
> 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
[quoted text clipped - 4 lines]
>
> 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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.