473,811 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why does the Process event - Exited close by its own?

28 New Member
I'm getting some very strange errors with my code and I'm not sure what's causing it. :( Basically, I'm trying to make a program which will list all the running programs as well as getting the icon from it. I've got it working prety well but I need it to update when ever a program is closed. So I looked into it a bit and found the I could use p.Exited event. I tried it out (in the bellow code) and it sort of worked however on a MessageBox.Show () works??? I try to do anything else it just closes the form down? why does this happen? am i doing anything wrong?

Expand|Select|Wrap|Line Numbers
  1.         bar.Controls.Clear()
  2.         For Each p As Process In Process.GetProcesses()
  3.             Dim procFile As String
  4.             Try
  5.                 procFile = p.Modules(0).FileName
  6.             Catch generatedExceptionName As Win32Exception
  7.                 procFile = "n/a"
  8.             End Try
  9.             Dim name As String = p.ToString()
  10.  
  11.             name = name.Replace("System.Diagnostics.Process (", "")
  12.             name = name.Replace(")", "")
  13.  
  14.  
  15.             If (procFile = "n/a" Or name = "explorer") Then
  16.  
  17.             Else
  18.                 If (p.MainWindowHandle.ToInt32() > 0) Then
  19.                     Dim icon As Button = New Button
  20.  
  21.                     icon.Width = 153
  22.                     icon.Height = 41
  23.                     icon.Text = name
  24.                     icon.BackgroundImageLayout = ImageLayout.Stretch
  25.                    Dim ProgIcon As Icon = System.Drawing.Icon.ExtractAssociatedIcon(procFile)
  26.                      icon.Image = ProgIcon.ToBitmap()
  27.                     Me.ToolTip1.SetToolTip(icon, name)
  28.                     p.EnableRaisingEvents = True
  29.                     AddHandler p.Exited, AddressOf ProgramClosed                    
  30. bar.Controls.Add(icon)
  31.                 End If
  32.             End If
  33.  
  34.  
  35.  
Feb 8 '11 #1
0 1126

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

Similar topics

1
339
by: Ruslan Shlain | last post by:
I am writing a Windows service. I have a timer that is set to 5 seconds. On the elapsed event i stop my timer and i start a process that triggers an exe app. It all works fine until I need to see when the exe finished its work. I tried to use the following code to capture the event. Any code samples or advice would be great. This code is in Class1 static void Main(string args) {
0
1346
by: Daniel Xiao | last post by:
I have used the following method to set the running priority for a process and its affiliated threads. It is noticable at statement (*) that if the process has already exited, the method will return immediately without further operations. However, sometimes the method may generate the following exception: =========================================================== 03/07/04 3:48:06 AM auto_rep.Run() error:...
1
5999
by: solex | last post by:
Hello All, Hopefully someone has run into this error. I have written a class(source below) that launches a thread to monitor the StandardOutput of a System.Diagnostics.Process, in particular I am executing the find.exe program. The application works perfectly in the development environment. As soon as I execute the compiled program and start the find process I get an "Application Error". The error states that the instruction...
4
2135
by: Guy Noir | last post by:
Hello. OK, Thanks to the help I have the remote debugging worked out. Here is my next hurdle. I have a service that is supposed to be catching Event Log written events. this.eventLog1.EntryWritten += new System.Diagnostics.EntryWrittenEventHandler(this.eventLog1_EntryWritten);
3
2874
by: bg_ie | last post by:
Hi, I'm starting a process as follows - Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = installValue + "\\Lib\\site-packages\ \pythonwin\\Pythonwin.exe"; process.StartInfo.Arguments = "/run " + script;
8
3229
by: Lonifasiko | last post by:
Hi, Using Process class I asynchronously launch an executable (black box executable) file from my Windows application. I mean asynchronously because I've got an EventHandler for "Exited" event. Therefore, when process finishes, "Exited" event is raised. This executable writes a long file for over 1-5 minutes, and I, from my application must read that file while is being generated.
3
5655
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 application called MapInfo using Interop. We need to be able to somehow figure out when the user exits the MapInfo applicaiton so we can close our own app as well. I was looking on SetWindowsHookEx function but couldn't make it work. Thanks for any...
9
7677
by: kimiraikkonen | last post by:
Hello, I want to automate something and display a simple msgbox that indicates my external process finished processing and "exited". My code is that, what things should i add more: Dim psInfo As New System.Diagnostics.ProcessStartInfo("bla.exe", "-b ") psInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
0
1182
by: quangnd0003 | last post by:
I have a event to Cancel Delete of user : private void dataGridViewKV_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { string maKV = e.Row.Cells.FormattedValue.ToString(); string tenKV = e.Row.Cells.FormattedValue.ToString(); string message = string.Format( "Are you sure want to delete {0} ?", tenKV, maKV);
6
2072
by: Ashutosh Bhawasinka | last post by:
Hi, I am starting a process and I need to monitor it (wait and check if its still responding). But, I it seems that the Process.HasExited or Process.Exited doesn't work. I just need to know if the process is running & responding. I am using
0
9727
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10133
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7669
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.