Posted on 2012-03-22
I am looking for at counding the number of active threads at any one time.
The best I can do is
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Processes Name"
Label2.Text = "Total = "
Button1.Text = "Get Current Processes"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim count As Integer = 0
label2.Text = "Total = "
Dim prs As Process() = Process.GetProcesses()
For Each proces As Process In prs
count += 1
Label2.Text += count.ToString()
Dim proc As Process = Process.GetCurrentProcess()
MsgBox("Number of Threads active: " & proc.Threads.Count.ToString(), MsgBoxStyle.Information, "Threads Active")
The problem is I originally tapped this up in VS2010, and throught bonza, its working... on an Windows Server 2003 box in a development environment it again showed consisten results, however it didnt run on the production box because of not having .NET 4 installed so dropped it down to .Net 3.5 via VS 2008 and then the thread count is out by 7 on the dev box, but spot on on my machine where it was originally built.
Any ideas welcome...