BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pipes (IPC) and multithreading

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Simon Guertin
Guest





PostPosted: Mon May 30, 2005 12:52 pm    Post subject: pipes (IPC) and multithreading Reply with quote



Hi, I am trying to create 2 applications that are communicating with
Pipes in windows XP. I succesfully created the channel and they can both
send back messages. I am having problems in the design issue of my
application. I would need to know how I should design the application so
it can work with the UI so I can send en message from one aplication to
the other and also receive messages from the other one. I tried to start
a new thread that waits for messages coming from the pipe using
afxCreateThread. So in general I would only like to know the right way
to design both apps so the UI is not blocked by the thread that is
waiting a communication and I can send messages using buttons clicks and
also receives messages from the other application and uptdate the UI
accordingly.

I think I will need a thread for this and a synchronized list of objects
that is shared buy the 2 objects (main thread and Pipe Thread) The main
thread could put messages to send to the pipe in this list fifo object
and the pipe thread reads from this fifo object.

Thank you for any hints

Simon
Back to top
JD
Guest





PostPosted: Tue May 31, 2005 2:47 am    Post subject: Re: pipes (IPC) and multithreading Reply with quote




Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:
Quote:

Hi, I am trying to create 2 applications that are
communicating with Pipes in windows XP. [...]

You need to be more specific with what it is that you are trying to accomplish - not how you are trying to accomplish it.

Quote:
[...] so it can work with the UI so I can send en message
from one aplication to the other and also receive messages
from the other one.

The win32 API SendMessage will easily handle sending message
and if you override each application's main forms WndProc
method, you can recieve notification of the sent message.

Quote:
[...] I would only like to know the right way to design both
apps so the UI is not blocked by the thread that is waiting

I doubt that you need a thread at all but I need to know more
about what you expect to accomplish.

Quote:
[...] and the pipe thread reads from this fifo object.

FIFO is the way to go but again, you most likely don't need a
thread. Please elaborate.

~ JD


Back to top
Simon Guertin
Guest





PostPosted: Tue May 31, 2005 5:38 pm    Post subject: Re: pipes (IPC) and multithreading Reply with quote



Hi again, I am sorry for the lack of information that I provided.
My application is using MFC and is a normal GUI application. My only
concern is how to implement the communication with the named pipes. When
I tried to read the pipe to wait for a message coming from another
application the function is blocking. ReadFile(...);
So as I understand I don't have to create another thread?
the 2 application use GUI and the communicate through the names pipes.

Both application needs to update the UI when some message are put in the
pipes.

thanks again

Simon


JD wrote:
Quote:
Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:

Hi, I am trying to create 2 applications that are
communicating with Pipes in windows XP. [...]


You need to be more specific with what it is that you are trying to accomplish - not how you are trying to accomplish it.


[...] so it can work with the UI so I can send en message
from one aplication to the other and also receive messages
from the other one.


The win32 API SendMessage will easily handle sending message
and if you override each application's main forms WndProc
method, you can recieve notification of the sent message.


[...] I would only like to know the right way to design both
apps so the UI is not blocked by the thread that is waiting


I doubt that you need a thread at all but I need to know more
about what you expect to accomplish.


[...] and the pipe thread reads from this fifo object.


FIFO is the way to go but again, you most likely don't need a
thread. Please elaborate.

~ JD


Back to top
JD
Guest





PostPosted: Wed Jun 01, 2005 12:12 am    Post subject: Re: pipes (IPC) and multithreading Reply with quote


Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:
Quote:

[...] sorry for the lack of information

I understand that you want to send messages between 2
applications and I presume that you've worked out how to
find the HWND's. I also understand that you want to exchange
information between these applications but I don't know why or
what type of imformation and I'm guessing that using named
pipes may not be the best choice.

You were quite specific about what you were doing. What I
wanted to know was what you expected to accomplish - not how
you expected to do it.

Quote:
[...] So as I understand I don't have to create another thread?

It's difficult to say with certainty without knowing more
I doubt it. If the communication between the applications
results in one or the other or both constantly being busy
processing the data packets, then you might need a worker
thread just to allow the main thread enough idle time so
that the GUI doesn't appear frozen and can respond in a
timely fashion to clicks and refreshing.

Please elaborate on the type of information that is being
exchanged, when it's exchanged, how often it is exchanged
and how the information is used once it's been exchanged.

~ JD


Back to top
Simon Guertin
Guest





PostPosted: Wed Jun 01, 2005 3:30 pm    Post subject: Re: pipes (IPC) and multithreading Reply with quote

Thank you very much for the quick replys.
The purpose of the application in the Task bar is to add shortcut items
(small buttons) so the user can click on them. Those buttons will be
displayed only when the main application (a normal application) detects
some special issu that needs a user interventions.

This main application will be most of the time minimized in the system
tray. So when the main application detects a situation that needs a user
intervention (lost of connection to a Wifi Hotspot for example) it will
send a message to the DeskBand application to display a certain button
that will be flashing. Then when the button is showing (in the task bar)
and the user clicks on it it will send back another message to the Main
application that the users wants to launch the intervention routines
(the application will launch a dialog (for the user to click on to
change some parameters)

Also the main application will send updates messages to the task bar to
display certain status of the application.

I hope this is more precise.

JD wrote:
Quote:
Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:

[...] sorry for the lack of information


I understand that you want to send messages between 2
applications and I presume that you've worked out how to
find the HWND's. I also understand that you want to exchange
information between these applications but I don't know why or
what type of imformation and I'm guessing that using named
pipes may not be the best choice.

You were quite specific about what you were doing. What I
wanted to know was what you expected to accomplish - not how
you expected to do it.


[...] So as I understand I don't have to create another thread?


It's difficult to say with certainty without knowing more
I doubt it. If the communication between the applications
results in one or the other or both constantly being busy
processing the data packets, then you might need a worker
thread just to allow the main thread enough idle time so
that the GUI doesn't appear frozen and can respond in a
timely fashion to clicks and refreshing.

Please elaborate on the type of information that is being
exchanged, when it's exchanged, how often it is exchanged
and how the information is used once it's been exchanged.

~ JD


Back to top
JD
Guest





PostPosted: Wed Jun 01, 2005 7:13 pm    Post subject: Re: pipes (IPC) and multithreading Reply with quote


Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:
Quote:


Please trim your posts.

Quote:
[...] So when the main application detects a situation that
needs a user intervention [...] it will send a message to
the DeskBand application [...]

What you have explained can all be handled with the win32
API SendMessage all by itself. Look at the WPARAM and LPARAM
parameters to include additional information. If the're not
enough, you can send messages to setup the data before you
send the execute message. You can also use WM_COPYDATA if
you find that the W/LPARAMS just don't cut it.

~ JD


Back to top
JD
Guest





PostPosted: Thu Jun 02, 2005 3:02 am    Post subject: Re: pipes (IPC) and multithreading Reply with quote


Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:
Quote:


It occured to me that you most likely also do not need a
second application. Hvae you considered using a thread for
that instead?

~ JD


Back to top
Simon Guertin
Guest





PostPosted: Thu Jun 02, 2005 2:35 pm    Post subject: Re: pipes (IPC) and multithreading Reply with quote

JD wrote:
Quote:
Simon Guertin <sguertin_AT (AT) trellianetworks (DOT) com> wrote:


It occured to me that you most likely also do not need a
second application. Hvae you considered using a thread for
that instead?

~ JD

At the moment we do not want the DeskBand to slow down our application

or interfere with it. Also, the Deskband is developped with VisualC++
..NET and our main application is developped using Borland C++Builder. I
was unable to succesfully compile and run a desk band with Borland.


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.