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 ?
dvplayltdAsked:
Who is Participating?
 
Dariusz DziaraConnect With a Mentor ProgrammerCommented:
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
 
Dariusz DziaraProgrammerCommented:
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
jkrConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.