Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

Find threads belongs to object ?

Hello experts !

How can I find what thread belongs to object ?
I have DirectShow FilterGraph (IFilterGraph) that contains some filters. FilterGraph have some threads and I want to find all of them. How to do it ?
  • 3
  • 2
2 Solutions
I have not checked it but:

You can call GetCurrentProcessId() to get ID of you process,
call GetCurrentThreadId() to get ID of current thread and

use "Tool Help Functions" to enumerate all threads and find all threads that has your process ID as parent process id


Call CreateToolhelp32Snapshot()

and then

Thread32First(), Thread32Next()
dvplayltdAuthor Commented:
I use FilterGraph that hold DirectShow filters. SOme DirectShow fileters may have thread and I think that they are child for FilterGraph. Using parent/child will help me get DirectShow filters thread.

But how to find thread of FilterGraph ?
Is using GetCurrentThreadId on code where is created  FilterGraph will tell me ThreadId of FilterGraph ?
As far as I know FilterGraph uses so called application thread  - thread on which object has been created (so I think GetCurrentThreadId() should be what you need) & there can be one or more working threads created later.

If you want however find working threads ... that's a problem. If you have control over thread creation you can simple store somewhere their IDs.

Additional working threads will be created after graph is run so you could enumerate threads before start & enumerate after & find new threads (just idea).

I don't want to lie but I think there's no such relation like parent thread-child thread.

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

dvplayltdAuthor Commented:
Thank you mrblue but I can NOT use enumerate before and enumerate after, because meantime my Process may create another threads. it look like I have to forgot about  easy way and maybe skip idea.

I will wait one- two days to see other answers and if do NOT - I will accept your aswer.
Unless you hook the thread creation, you'll hardly be able to associate a certain thread with an associated DirectX object later on. There also might be some threads that aren't even related to DirectX.
dvplayltdAuthor Commented:
thank you jkr, your answer is correct but mrblue was first :)

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now