-2

I would like to identify my background worker thread id.

When I call RunWorkerAsync() method it creates a working thread. Naturally, I can get a list with all threads from Process.GetCurrentProcess().Threads method but this list has lots of threads ids and I don't know how to identify my worker thread id.

It's possible that when I call RunWorkerAsync() method immediately get this thread id?

Like this

enter image description here

Thank you!

Gergo Papp
  • 19
  • 1
  • 5

1 Answers1

0

you can do that like this

int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;

If you what the current process id where all your threads lives.

int processId = System.Diagnostics.GetCurrentProcess().Id;
ArunPratap
  • 4,816
  • 7
  • 25
  • 43