473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Process.CloseMainProgram() - not always working

84
Hi Guys,
I am having a problem here and need some urgent help from anyone possible??


I have Application 1 which triggers Application 2. Application 2 runs some checks and if it is validated, it closes Application 1. Hence i need to close Application 1 from Application 2.

Now i have process.CloseMainProgram() in Application 2 which works most of the time, but it sometimes leaves Application 1 running. I have added a WndProc overide in Application 1 to track when it recieved a WM_CLOSE or windows instructions to close the application. Apparently when Application 1 is stuck - there is no WM_CLOSE recieved by it and i am not sure why this happens.

Please help guys - as this is quite urgent and i am running out of ideas.
Jan 26 '09 #1
4 1556
artov
40
Have you thought on using named Mutex? Named mutex are unique to the system, so you can use them on communicating between processes.
Jan 27 '09 #2
alag20
84
I already used those. Anyways i found a way yo dll import user32.dll and send WM_CLOSE manually - rather than via .Net code.
Jan 27 '09 #3
vekipeki
229 Expert 100+
If Application1 is stuck, then you will hardly be able to close it without using Process.Kill(). But your bigger problem is that your Application shouldn't get stuck in the first place, so consider finding the cause to that problem first.

Using Mutexes to send simple notifications between .NET apps should be a better way to do it than sending windows messages manually. It allows you greater flexibility.

WM_CLOSE closes the application, but one day you might decide that App2 could have more states than just validated/not validated - in that case you could use an extra event which can be processed in App1 (or in any other application -- App2 doesn't even have to know if App1 exists - it only fires an event and continues doing its job).
Jan 27 '09 #4
alag20
84
@vekipeki
I agree but the problem i am having is that App1 never hangs. It is just that CloseMainWindow never delivers the close message to App1 [sometimes], so thats why i am sending cutom WM_CLOSE.

Thanks anyways for your help.
Jan 27 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: PMac | last post by:
I'm trying to execute a stand-alone console application from an aspx page when a use clicks a button on that page. On the aspx page is the following lines of pertinent code: private void...
4
by: Jesse Cates via DotNetMonster.com | last post by:
I am trying to launch a command-line program that came with a program called Live Stats. This command-line program is used to automate configuration of Live Stats. In order to test this, I am just...
0
by: Filipe Marcelino | last post by:
Hi, I whant to know if a user is using a process. To achieve that I have to know the state of the process, so I wrote the following code: Dim localAll As Process() =...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
1
by: Joey | last post by:
I am using the below code to run a dos based program. While it is running you can hit ctrl-c to cancel the process. Does anyone know how I can send the same keystroke to the already runing...
5
by: Benzi Eilon | last post by:
I have written a C# application which should run as a Windows Service. I must avoid having multiple instances of the application on one machine so I inserted the following code at the beginning of...
3
by: Brad | last post by:
In a Vista/IIS7 asp.net app, a coded crystal report export is crashing IIS7....but it works just fine in visual studio's cassini web server. And if I create a web form and use the crystal...
3
by: jan.loucka | last post by:
Hi, Is there any way in .NET how to capture WIN API messages that belong to different application? We have a Windows Form app written in .NET 2.0 and from our application we're running another...
1
by: Michael Torrie | last post by:
I have a small multi-threaded program that spawns a number of threads that each spawn a particular process in a particular temporary directory. My problem is that using os.chdir to change the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.