Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

multiple versions of exe running - how to manage it so only 1 is running?

I have a console app, which isn't closing properly....i.e.

After closing the console application, the window disappears, but the process is remaining in the task manger

I believe the active X control is responsible, however, I need a way to get rid of it in task manger
When i reopen it/close i end up with multiple versions running in task manger and its causing issues


I would like to add code a line of code which can "kill" the previous running process for the same console application.


I have tried these two cases
Case 1:
 AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); 

 static void CurrentDomain_ProcessExit(object sender, EventArgs e)
        {
            foreach (var process in Process.GetProcessesByName("FlirAdapterConsole"))
            {
                process.Kill();
            }
        }

Open in new window

When I close the console app, this isn't getting called so this doesn't work


Case 2 :
 
 [STAThread]
        static void Main()
        {
            

            foreach (var process in Process.GetProcessesByName("FlirAdapterConsole"))
            {
                process.Kill();
            }

Open in new window

This is supposed to kill any previous instances of the app running in task manager, but instead it actually closes the current app
 

This code is for closing apps that have the name "FlirAdapterConsole"

     foreach (var process in Process.GetProcessesByName("FlirAdapterConsole"))
            {
                process.Kill();
            }

Open in new window


I have tried using these names instead
FlirAdapterConsole.exe
FlirAdapterConsole.exe *32

but the apps do not close

any help appreciated!
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you tried killing the active x instead? What activex is it?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial