title: getting the thread id of threads in the threadpool from outside threadprocessing method
body: <p>I am implementing multi-threading concepts using thread-pooling to pick up messages from queues. There is a necessity that the id/number of the thread which picks up a particular message has to be accessed from outside the thread method. Supposes if there are three threads and they have to pick up 5 messages from the queue. the first thread picks up the first message processes it and it is released. meanwhile the second thread would have picked up some other message and would've started to process it(multi-threading).
  Here from some other method, i want to know which thread actually picks up message1, and the consistency has to maintained not only inside the threading function but throughout the application(from outside the thread function also).
  i have implemented multi-threading as follows</p>
  
  <pre><code>For m_intThread1 = 0 To m_stuTPConfig.intNumThreads - 1
      ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf **MultiProcessMQ**), m_intThread1)
      System.Threading.Thread.Sleep(1000)
  Next m_intThread1 'm_intThread
  
  Public Shared Sub MultiProcessMQ(ByVal state As Object)
      Dim objParentProcess As New ParentProcess
      objParentProcess.ProcessThread(CType(state, String))
      If Interlocked.Decrement(CInt(m_stuTPConfig.intNumThreads)) = 0 Then
          m_asyncOpsAreDone.Set()
      End If 'Interlocked.Decrement(CInt(m_stuTPConfig.intNumThreads)) = 0
  End Sub 'MultiProcessMQ()
  
  Public Sub ProcessThread(ByVal strThread As String)
      intThrd = Convert.ToInt32(strThread)
      Console.WriteLine("Parent Thread started " &amp; strThread)
  End Sub
  </code></pre>
  
  <p>How do i access the variable <strong>strThread</strong> From another method and maintain its consistency.This is required for logging purposes.</p>
  
  <p>Thanks for formatting. We are using WCFMQAdapter services which is a for configuring the app in accordance with the input and output queues. once I host this service from <strong>ProcessThread</strong> the control goes to some other file, say a service.vb file wherein all the operations pertaining to the thread are performed and never comes back. The actual usage of threads here are for logging the processing details onto a file in the service.vb file. Now the PROCESSTHREAD method is called. till now the multithreading properties are maintained. once the service is hosted how to pass on these thread info to the service.vb. Or should there be a parent threading/child threading concept? And, if i obtain a threadid using managedThreadId, dynamic thread ids are generated. Are there any chances to obtain them and convert it into user managed ids. say, instead of thread 21,thread 44,thread66,thread89........ can we convert them like thread1, thread 2, thread 3, thread 4?                                                                   Thanks in Advance :-)</p>