Learn how to a build a cloud-first strategyRegister Now

x
  • 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 ?
0
dvplayltd
Asked:
dvplayltd
  • 3
  • 2
2 Solutions
 
mrblueCommented:
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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/tool_help_functions.asp

Call CreateToolhelp32Snapshot()
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/createtoolhelp32snapshot.asp

and then

Thread32First(), Thread32Next()
0
 
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 ?
0
 
mrblueCommented:
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.

0
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.
0
 
jkrCommented:
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.
0
 
dvplayltdAuthor Commented:
thank you jkr, your answer is correct but mrblue was first :)
0

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