Non ho idea sui "mezzi" di VS...però ho pensato ad una soluzione basata sul PerfomanceCounter...nella speranza che non sia una sega mentale...
codice:
Public Class Form1
Dim PC_cpu_Usata As New PerformanceCounter
Dim processo As Process
Dim loop_attuale As String
Dim log As String
Private Sub Form1_Load() Handles MyBase.Load
log = ""
loop_attuale = ""
processo = Process.GetCurrentProcess
With PC_cpu_Usata
.CategoryName = "processo"
.CounterName = "% tempo processore"
.InstanceName = processo.ProcessName
End With
Timer1.Interval = 500
Timer1.Start()
End Sub
Private Sub Timer1_Tick() Handles Timer1.Tick
If System.Math.Round(PC_cpu_Usata.NextValue, 0) > 40 Then
log = log & loop_attuale & " - cpu= " & _
System.Math.Round(PC_cpu_Usata.NextValue, 0) & "%" & vbCrLf
End If
End Sub
End Class
La pecca è che al posto di Debug.Print devi impostare la variabile "loop_attuale" per identificare il codice che stà "girando" e che impegna la cpu per più del 40%.
Ho usato una String (log) per scrivere la traccia, vedi tu cosa ti è più comodo.
Ciao