Detect the running thread

  • Thread starter Thread starter Samuel
  • Start date Start date
S

Samuel

Hi

I would like to put a condition in a method that is based on whether or not
the method was loaded on to the main thread of the application or another
thread (I do not want the user to see any messaged triggered by the other
threads).

Thank you
Samuel
 
Samuel said:
Hi

I would like to put a condition in a method that is based on whether or not
the method was loaded on to the main thread of the application or another
thread (I do not want the user to see any messaged triggered by the other
threads).

Well,,, it's always running in System.Threading.Thread.CurrentThread.
Why do you care? A thread's behavior should be controlled by
options/settings, IMO.


Armin
 
I would like to put a condition in a method that is based on whether or not
the method was loaded on to the main thread of the application or another
thread (I do not want the user to see any messaged triggered by the other
threads).

In the gui/main thread, capture the main thread object in a module, eg:

Public MainThread As Threading.Thread = Threading.Thread.CurrentThread()

Where you want to test, do something like this:

If System.Threading.Thread.CurrentThread() Is MainThread Then
' running on main thread
Else
' running on another thread
End If
 
Hi

I would like to put a condition in a method that is based on whether or not
the method was loaded on to the main thread of the application or another
thread (I do not want the user to see any messaged triggered by the other
threads).

Thank you
Samuel

Can you be more specific about the messages that are triggered by the
other threads? What kind of messages are you talking about? How are
they stored? How are they triggered exactly?
 
Thank you

Works beautifully


AMercer said:
In the gui/main thread, capture the main thread object in a module, eg:

Public MainThread As Threading.Thread = Threading.Thread.CurrentThread()

Where you want to test, do something like this:

If System.Threading.Thread.CurrentThread() Is MainThread Then
' running on main thread
Else
' running on another thread
End If
 
Back
Top