?
Solved

Monitoring Threads from a 3rd Party API

Posted on 2004-11-09
1
Medium Priority
?
298 Views
Last Modified: 2010-04-15
I am using a third party multithreaded API within my application to handle the receiving of real-time data.  Is there a way within my application to monitor the threads that the API creates and whether they are finished working or not?  I am programming in C using Visual Studio .net.  Any and all help would be appreciated, as well as any sample code.
0
Comment
Question by:jtrades
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 1500 total points
ID: 12536216
>>Is there a way within my application to monitor the threads that the API creates and whether they are finished
>>working or not?

You can do that by providing a simple DLL that is loaded before you use any of these APIs. All you have to do is to provide a 'DllMain()' which will get notified about the threads:

// DllMain() is the entry-point function for this DLL.
BOOL
WINAPI
DllMain ( HINSTANCE, DWORD dwReason, LPVOID) {

    DWORD dwTID = 0;

    switch ( dwReason) {
 
        // The attached process creates a new thread.
 
        case DLL_THREAD_ATTACH:

            dwTID = GetCurrentThreadId ();  // grab the TID, since this code
                                            // is executing in the thread's
                                            // context
 
            break;
 
        // The thread of the attached process terminates.
 
        case DLL_THREAD_DETACH:
 
            dwTID = GetCurrentThreadId ();
           
            break;
 
        default:
            break;
    }
 
    return TRUE;
}

This way, you can easily keep track about thread creation and termination.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question