Re: CEvent instance shared between apps ?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On 6 mai, 13:39, ChrisN <chrisn...@xxxxxxxxxxxxxxxxxxxxx> wrote:
On Tue, 6 May 2008 02:01:31 -0700 (PDT), Phil <pbruy...@xxxxxxxxx>
wrote:

This works great, except when I run multiple instances of my
application on the same
computer. When I click the "Stop" button of one app to exit its
thread, the other threads created by the
other applications stop too! I would not expect the CEvent object
being shared by the apps!
What did I do wrong?
I also declared the controlling function as a static member of
MyAppDlg, with the same result :(

You'll get the behaviour you describe if you specified a name for the
event object when it was constructed:

CEvent Event( FALSE, FALSE, _T( "MyEvent" ), NULL );

This creates an event that is shared between processes.

To ensure that the event is unique to each process, specify NULL for
the lpszName parameter:

CEvent Event( FALSE, FALSE, NULL, NULL );

Chris

Thank you so much Chris !
Indeed, I had named my events. Specifying NULL for the names solved
the problem.
Thanks again !
Phil
.


Quantcast