GetProcessesByName XP SP2 Bug?

  • Thread starter Thread starter JZ
  • Start date Start date
J

JZ

Hi,

Has anyone else got this?
I've downloaded the IT Professional network version of XP SP2 to test my
programs.

I found a problem with GetProcessesByName it just seems to hang.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim processes() As Process
processes = Process.GetProcessesByName("MyProgram")
MessageBox.Show("Done!")

End Sub

Anybody?

Ideas?

Suggestions?
 
* "JZ said:
Has anyone else got this?
I've downloaded the IT Professional network version of XP SP2 to test my
programs.

I found a problem with GetProcessesByName it just seems to hang.

I suggest to post this question to one of the Whidbey groups:

<URL:http://communities.microsoft.com/newsgroups/default.asp?icp=whidbey>

Infos on how to view these groups with an NNTP news client:

<URL:http://communities.microsoft.com/newsgroups/ICP/whidbey/US/welcomePage.htm>

If you are sure that this is a bug, use MSDN Product Feedback Center to
report it:

<URL:http://lab.msdn.microsoft.com/productfeedback/>
 
Hi,

These links are for VS 2005.

My problem was with Windows XP Service pack 2.
As I didn't have the problem until I installed it.
 
Hi,

I'm not sure whether it is XP SP2, it might just be my PC.

However, just in case anyone else is reading this, I found a work around for
what I needed to do...

Dim appMutex As New System.Threading.Mutex(False, "MyApplicationName")
If appMutex.WaitOne(0, False) Then
'Application.Run(New MyMainForm())
Else
MessageBox.Show _
("Can not start because a previous instance of this application is
already running.")
End If
 
Your code is a lot like what I am using, but I noticed you are not releasing
your mutex. Not even sure of the ramifications of that, but here is what I
use...

HTH,
Greg

' code to start app...
Try
SingletonApp.Run(New MyMainForm, "8ca35a66-6e9a-41d4-a87d-d9755b1f88c4") '
arbitrary GUID
Catch ex As SingletonException
MsgBox("Can not start because a previous instance of this application is
already running!")
End Try



' code inside singletonapp.vb file
Option Strict On

Imports System.Threading

Public Class SingletonApp

Private Shared _guid As String

Shared m_Mutex As Mutex
Public Shared Sub Run(ByVal mainForm As Form, ByVal guid As String)
_guid = guid
If (IsFirstInstance()) Then
AddHandler Application.ApplicationExit, AddressOf OnExit
Application.Run(mainForm)
Else
Throw New SingletonException
End If
End Sub
Public Shared Function IsFirstInstance() As Boolean
m_Mutex = New Mutex(False, _guid)
Dim owned As Boolean = False
owned = m_Mutex.WaitOne(TimeSpan.Zero, False)
Return owned
End Function

Public Shared Sub OnExit(ByVal sender As Object, ByVal args As
EventArgs)
m_Mutex.ReleaseMutex()
m_Mutex.Close()
End Sub
End Class

Public Class SingletonException

Inherits System.ApplicationException

Public Sub New()
MyBase.New("Program already running!")
End Sub

Public Sub New(ByVal InnerException As Exception)
MyBase.New("Program already running!", InnerException)
End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top