raising an event from one application to another

  • Thread starter Thread starter Paolo Liverani
  • Start date Start date
P

Paolo Liverani

I would like to know if there an ad hoc way (in .NET) to send a message from
an application to a second application (on the same machine) so that I can
raise an event on the second one.
My target is to run only one instance of an application and if a second one
is fired the second one should send a message to the first one and then die.
Many thanks,
Paolo Liverani
 
Hello Paolo,

Thanks for posting in the group.

After reviewing your post, I think the question is: How to prevent two
instances of .net application running simontaneously? Please correct me if
I have misunderstood the problem.

In order to achieve it, surely we could use typical win32 ways to send a
customized message for one application to another. However, in this way, we
need to search for window first. I recommend you use Mutex in .NET to do
so. Please refer to MSDN article "HOWTO: Limit 32-bit Applications to One
Instance Using C++"
http://support.microsoft.com/?id=243953

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Paolo Liverani" <[email protected]>
!Subject: raising an event from one application to another
!Date: Fri, 22 Aug 2003 10:48:18 +0200
!Lines: 9
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:51911
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!I would like to know if there an ad hoc way (in .NET) to send a message
from
!an application to a second application (on the same machine) so that I can
!raise an event on the second one.
!My target is to run only one instance of an application and if a second one
!is fired the second one should send a message to the first one and then
die.
!Many thanks,
! Paolo Liverani
!
!
!
 
Hi Yan-Hong,
what I apologize but I don't want only to prevent two instances of the
same application running simoultaneously.
I would like that if a second instance is fired, it should:
1) check if there is a previous instance running.
2) if there is already a prevoius instance:
a) send a message to the previous so that the previous one can do a task
b) die
The purpose is to handle when a PocketPC is connected using the registry key
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows CE
Services\AutoStartOnConnect. If the program is not running it should be
fired and when the device is disconnected the program should be left
running. As soon as the PocketPC is reconnected a second program is fired
but what I really like is having a message sent to the already running
program.
Thank you,
Paolo Liverani
 
Hello Paolo,

Thanks for the quick response.

Does the application have a window? If so, I think you could use PInvoke to
call typical Win32 APIs to achieve it.

To send message, we could call SendMessage or PostMessage.

To detect former instance, we could use FindWindow.

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Paolo Liverani" <[email protected]>
!References: <[email protected]>
<[email protected]>
!Subject: Re: raising an event from one application to another
!Date: Mon, 25 Aug 2003 08:31:42 +0200
!Lines: 79
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52097
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!Hi Yan-Hong,
! what I apologize but I don't want only to prevent two instances of the
!same application running simoultaneously.
!I would like that if a second instance is fired, it should:
!1) check if there is a previous instance running.
!2) if there is already a prevoius instance:
! a) send a message to the previous so that the previous one can do a
task
! b) die
!The purpose is to handle when a PocketPC is connected using the registry
key
!HKEY_LOCAL_MACHINE\Software\Microsoft\Windows CE
!Services\AutoStartOnConnect. If the program is not running it should be
!fired and when the device is disconnected the program should be left
!running. As soon as the PocketPC is reconnected a second program is fired
!but what I really like is having a message sent to the already running
!program.
!Thank you,
! Paolo Liverani
!
!!> Hello Paolo,
!>
!> Thanks for posting in the group.
!>
!> After reviewing your post, I think the question is: How to prevent two
!> instances of .net application running simontaneously? Please correct me
if
!> I have misunderstood the problem.
!>
!> In order to achieve it, surely we could use typical win32 ways to send a
!> customized message for one application to another. However, in this way,
!we
!> need to search for window first. I recommend you use Mutex in .NET to do
!> so. Please refer to MSDN article "HOWTO: Limit 32-bit Applications to One
!> Instance Using C++"
!> http://support.microsoft.com/?id=243953
!>
!> Hope that helps.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "Paolo Liverani" <[email protected]>
!> !Subject: raising an event from one application to another
!> !Date: Fri, 22 Aug 2003 10:48:18 +0200
!> !Lines: 9
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !Message-ID: <[email protected]>
!> !Newsgroups: microsoft.public.dotnet.framework
!> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:51911
!> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !
!> !I would like to know if there an ad hoc way (in .NET) to send a message
!> from
!> !an application to a second application (on the same machine) so that I
!can
!> !raise an event on the second one.
!> !My target is to run only one instance of an application and if a second
!one
!> !is fired the second one should send a message to the first one and then
!> die.
!> !Many thanks,
!> ! Paolo Liverani
!> !
!> !
!> !
!>
!
!
!
 
Thank you for your answer Yan-Hong.
Actually I am already using PostMessage but I was wandering if there was a
..Net way to do that.
Paolo
 
Ok, thank you a lot Yan-Hong.
Regards,
Paolo
Yan-Hong Huang said:
Hello Paolo,

Since you need to notify the former application and let it do some tasks,
so we need a interprocess communication here. Sending message is a method.
Surely we could also use Socket, NamePipe or even filemapping to do it. In
NET framework, I can't think of an easy way to do so.

Thanks.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Paolo Liverani" <[email protected]>
!References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
!Subject: Re: raising an event from one application to another
!Date: Mon, 25 Aug 2003 15:24:44 +0200
!Lines: 141
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52129
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!Thank you for your answer Yan-Hong.
!Actually I am already using PostMessage but I was wandering if there was a
!.Net way to do that.
! Paolo
!
!!> Hello Paolo,
!>
!> Thanks for the quick response.
!>
!> Does the application have a window? If so, I think you could use PInvoke
!to
!> call typical Win32 APIs to achieve it.
!>
!> To send message, we could call SendMessage or PostMessage.
!>
!> To detect former instance, we could use FindWindow.
!>
!> Hope that helps.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "Paolo Liverani" <[email protected]>
!> !References: <[email protected]>
!> <[email protected]>
!> !Subject: Re: raising an event from one application to another
!> !Date: Mon, 25 Aug 2003 08:31:42 +0200
!> !Lines: 79
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !Message-ID: <[email protected]>
!> !Newsgroups: microsoft.public.dotnet.framework
!> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52097
!> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !
!> !Hi Yan-Hong,
!> ! what I apologize but I don't want only to prevent two instances of
!the
!> !same application running simoultaneously.
!> !I would like that if a second instance is fired, it should:
!> !1) check if there is a previous instance running.
!> !2) if there is already a prevoius instance:
!> ! a) send a message to the previous so that the previous one can do a
!> task
!> ! b) die
!> !The purpose is to handle when a PocketPC is connected using the registry
!> key
!> !HKEY_LOCAL_MACHINE\Software\Microsoft\Windows CE
!> !Services\AutoStartOnConnect. If the program is not running it should be
!> !fired and when the device is disconnected the program should be left
!> !running. As soon as the PocketPC is reconnected a second program is
fired
!> !but what I really like is having a message sent to the already running
!> !program.
!> !Thank you,
!> ! Paolo Liverani
!> !
!> !!> !> Hello Paolo,
!> !>
!> !> Thanks for posting in the group.
!> !>
!> !> After reviewing your post, I think the question is: How to prevent two
!> !> instances of .net application running simontaneously? Please correct
me
!> if
!> !> I have misunderstood the problem.
!> !>
!> !> In order to achieve it, surely we could use typical win32 ways to send
!a
!> !> customized message for one application to another. However, in this
!way,
!> !we
!> !> need to search for window first. I recommend you use Mutex in .NET to
!do
!> !> so. Please refer to MSDN article "HOWTO: Limit 32-bit Applications to
!One
!> !> Instance Using C++"
!> !> http://support.microsoft.com/?id=243953
!> !>
!> !> Hope that helps.
!> !>
!> !> Best regards,
!> !> Yanhong Huang
!> !> Microsoft Online Partner Support
!> !>
!> !> Get Secure! - www.microsoft.com/security
!> !> This posting is provided "AS IS" with no warranties, and confers no
!> !rights.
!> !>
!> !> --------------------
!> !> !From: "Paolo Liverani" <[email protected]>
!> !> !Subject: raising an event from one application to another
!> !> !Date: Fri, 22 Aug 2003 10:48:18 +0200
!> !> !Lines: 9
!> !> !X-Priority: 3
!> !> !X-MSMail-Priority: Normal
!> !> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !> !Message-ID: <[email protected]>
!> !> !Newsgroups: microsoft.public.dotnet.framework
!> !> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!> !> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!> !> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:51911
!> !> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !> !
!> !> !I would like to know if there an ad hoc way (in .NET) to send a
!message
!> !> from
!> !> !an application to a second application (on the same machine) so that
I
!> !can
!> !> !raise an event on the second one.
!> !> !My target is to run only one instance of an application and if a
!second
!> !one
!> !> !is fired the second one should send a message to the first one and
!then
!> !> die.
!> !> !Many thanks,
!> !> ! Paolo Liverani
!> !> !
!> !> !
!> !> !
!> !>
!> !
!> !
!> !
!>
!
!
!
 
Hello Paolo,

You are welcome. :)

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Paolo Liverani" <[email protected]>
!References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<#[email protected]>
<[email protected]>
!Subject: Re: raising an event from one application to another
!Date: Tue, 26 Aug 2003 12:55:47 +0200
!Lines: 202
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52225
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!Ok, thank you a lot Yan-Hong.
!Regards,
! Paolo
!!> Hello Paolo,
!>
!> Since you need to notify the former application and let it do some tasks,
!> so we need a interprocess communication here. Sending message is a
method.
!> Surely we could also use Socket, NamePipe or even filemapping to do it.
In
!> NET framework, I can't think of an easy way to do so.
!>
!> Thanks.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!>
!> Get Secure! - www.microsoft.com/security
!> This posting is provided "AS IS" with no warranties, and confers no
!rights.
!>
!> --------------------
!> !From: "Paolo Liverani" <[email protected]>
!> !References: <[email protected]>
!> <[email protected]>
!> <[email protected]>
!> <[email protected]>
!> !Subject: Re: raising an event from one application to another
!> !Date: Mon, 25 Aug 2003 15:24:44 +0200
!> !Lines: 141
!> !X-Priority: 3
!> !X-MSMail-Priority: Normal
!> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !Message-ID: <#[email protected]>
!> !Newsgroups: microsoft.public.dotnet.framework
!> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52129
!> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !
!> !Thank you for your answer Yan-Hong.
!> !Actually I am already using PostMessage but I was wandering if there was
!a
!> !.Net way to do that.
!> ! Paolo
!> !
!> !!> !> Hello Paolo,
!> !>
!> !> Thanks for the quick response.
!> !>
!> !> Does the application have a window? If so, I think you could use
!PInvoke
!> !to
!> !> call typical Win32 APIs to achieve it.
!> !>
!> !> To send message, we could call SendMessage or PostMessage.
!> !>
!> !> To detect former instance, we could use FindWindow.
!> !>
!> !> Hope that helps.
!> !>
!> !> Best regards,
!> !> Yanhong Huang
!> !> Microsoft Online Partner Support
!> !>
!> !> Get Secure! - www.microsoft.com/security
!> !> This posting is provided "AS IS" with no warranties, and confers no
!> !rights.
!> !>
!> !> --------------------
!> !> !From: "Paolo Liverani" <[email protected]>
!> !> !References: <[email protected]>
!> !> <[email protected]>
!> !> !Subject: Re: raising an event from one application to another
!> !> !Date: Mon, 25 Aug 2003 08:31:42 +0200
!> !> !Lines: 79
!> !> !X-Priority: 3
!> !> !X-MSMail-Priority: Normal
!> !> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !> !Message-ID: <[email protected]>
!> !> !Newsgroups: microsoft.public.dotnet.framework
!> !> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it 213.82.187.5
!> !> !Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!> !> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52097
!> !> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !> !
!> !> !Hi Yan-Hong,
!> !> ! what I apologize but I don't want only to prevent two instances
of
!> !the
!> !> !same application running simoultaneously.
!> !> !I would like that if a second instance is fired, it should:
!> !> !1) check if there is a previous instance running.
!> !> !2) if there is already a prevoius instance:
!> !> ! a) send a message to the previous so that the previous one can do
!a
!> !> task
!> !> ! b) die
!> !> !The purpose is to handle when a PocketPC is connected using the
!registry
!> !> key
!> !> !HKEY_LOCAL_MACHINE\Software\Microsoft\Windows CE
!> !> !Services\AutoStartOnConnect. If the program is not running it should
!be
!> !> !fired and when the device is disconnected the program should be left
!> !> !running. As soon as the PocketPC is reconnected a second program is
!> fired
!> !> !but what I really like is having a message sent to the already
running
!> !> !program.
!> !> !Thank you,
!> !> ! Paolo Liverani
!> !> !
message
!> !> !!> !> !> Hello Paolo,
!> !> !>
!> !> !> Thanks for posting in the group.
!> !> !>
!> !> !> After reviewing your post, I think the question is: How to prevent
!two
!> !> !> instances of .net application running simontaneously? Please
correct
!> me
!> !> if
!> !> !> I have misunderstood the problem.
!> !> !>
!> !> !> In order to achieve it, surely we could use typical win32 ways to
!send
!> !a
!> !> !> customized message for one application to another. However, in this
!> !way,
!> !> !we
!> !> !> need to search for window first. I recommend you use Mutex in .NET
!to
!> !do
!> !> !> so. Please refer to MSDN article "HOWTO: Limit 32-bit Applications
!to
!> !One
!> !> !> Instance Using C++"
!> !> !> http://support.microsoft.com/?id=243953
!> !> !>
!> !> !> Hope that helps.
!> !> !>
!> !> !> Best regards,
!> !> !> Yanhong Huang
!> !> !> Microsoft Online Partner Support
!> !> !>
!> !> !> Get Secure! - www.microsoft.com/security
!> !> !> This posting is provided "AS IS" with no warranties, and confers no
!> !> !rights.
!> !> !>
!> !> !> --------------------
!> !> !> !From: "Paolo Liverani" <[email protected]>
!> !> !> !Subject: raising an event from one application to another
!> !> !> !Date: Fri, 22 Aug 2003 10:48:18 +0200
!> !> !> !Lines: 9
!> !> !> !X-Priority: 3
!> !> !> !X-MSMail-Priority: Normal
!> !> !> !X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!> !> !> !X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!> !> !> !Message-ID: <[email protected]>
!> !> !> !Newsgroups: microsoft.public.dotnet.framework
!> !> !> !NNTP-Posting-Host: host5-187.pool21382.interbusiness.it
!213.82.187.5
!> !> !> !Path:
!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!> !> !> !Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:51911
!> !> !> !X-Tomcat-NG: microsoft.public.dotnet.framework
!> !> !> !
!> !> !> !I would like to know if there an ad hoc way (in .NET) to send a
!> !message
!> !> !> from
!> !> !> !an application to a second application (on the same machine) so
!that
!> I
!> !> !can
!> !> !> !raise an event on the second one.
!> !> !> !My target is to run only one instance of an application and if a
!> !second
!> !> !one
!> !> !> !is fired the second one should send a message to the first one and
!> !then
!> !> !> die.
!> !> !> !Many thanks,
!> !> !> ! Paolo Liverani
!> !> !> !
!> !> !> !
!> !> !> !
!> !> !>
!> !> !
!> !> !
!> !> !
!> !>
!> !
!> !
!> !
!>
!
!
!
 
Back
Top