http://msdn.microsoft.com/en-us/library/ms682659(VS.85).aspx
http://social.msdn.microsoft.com/forums/en-US/vsdebug/thread/1d92fc36-3e42-4057-abbc-f162bdd226ac/
I believe anyone will see info in debugger window like this,
The thread 'Win32 Thread' (0xfbc) has exited with code 0 (0x0).
The program '[3264] xxxxx.exe: Native' has exited with code 0 (0x0).
If your application is multithread, you will see more "Win32 Thread" words in debugger window.
So my question is how to get every thread we have created exit status. In other word, how can we find the corresponding thread info based on debugger window.
let us see the example above. The thread 0xfbc, first, I think the value is the corresponding handle of the thread created. then I print this handle like this format "%08x". They are not the same value. I don't know geting the handle value is correct or not, if not, please remind me. If this conversion is true, how can we connect it with specific thread.
Another question, about exit code. I feel very puzzle. Though many people say if return value is zero, that definitely demonstrate that thread work fine. If not zero, thing seems complex. Some people say non-zero shows some trouble has happened. While other people say non-zero dosen't mean the thread is in trouble, it only show the status the thread return, also they say return value can be anything. At these words, It freak me out. If this is the case, how can I find out what has happened to the thread base on return code.
Hope anyone give me clues and any opinions will be much appreciated.
The thread 'Win32 Thread' (0xfbc) has exited with code 0 (0x0).
The program '[3264] xxxxx.exe: Native' has exited with code 0 (0x0).
If your application is multithread, you will see more "Win32 Thread" words in debugger window.
So my question is how to get every thread we have created exit status. In other word, how can we find the corresponding thread info based on debugger window.
let us see the example above. The thread 0xfbc, first, I think the value is the corresponding handle of the thread created. then I print this handle like this format "%08x". They are not the same value. I don't know geting the handle value is correct or not, if not, please remind me. If this conversion is true, how can we connect it with specific thread.
Another question, about exit code. I feel very puzzle. Though many people say if return value is zero, that definitely demonstrate that thread work fine. If not zero, thing seems complex. Some people say non-zero shows some trouble has happened. While other people say non-zero dosen't mean the thread is in trouble, it only show the status the thread return, also they say return value can be anything. At these words, It freak me out. If this is the case, how can I find out what has happened to the thread base on return code.
Hope anyone give me clues and any opinions will be much appreciated.
-
Answer
Hi Enrico,
The values shown in brackets e.g. 0xfbc are the thread ids assigned by the OS. These values will match up with what is shown in the Threads window.
As for the exit code value this is the value that the thread exited with. An exit code of 0 is used to mean there were no issues. However the developer can choose to have thread exit with whatever code they want. So they may choose exit codes that indicate an error occurred etc. Also take a look at ExitThread at http://msdn.microsoft.com/en-us/library/ms682659(VS.85).aspx and other methods related to this.
Azeem Khan
VS Debugger.Marked as answer by Azeem Khan - MSFT on 2008年9月4日 0:51:57 -
enrico00 - Posted on 2008年9月4日 22:56:27Azeem, thank you for your reply.
I examine the value according to your prompt. Yeah, you are right.
About exit code, I have make it clear.
About thread id and exit code, I have another question. In my app, I create four threads,when I exit the app,I get info from debugger window like this:
The thread 'Win32 Thread' (0xa14) has exited with code 1 (0x1).
The thread 'Win32 Thread' (0xfbc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x960) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x744) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe38) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe40) has exited with code 1 (0x1).
The program '[504] xxxxx.exe: Native' has exited with code 2(0x2).
According to thread id, I can identify exit with code 0 is created by my app. The remaing two threads are created by OS, so my question is how to deal with thread which is not created by app when the thread exit unsafely. Of course, the thread exit unsafely is due to the app's bug.
本文探讨了在多线程应用程序中如何理解线程ID和退出状态码的意义。特别是针对不同退出状态码所代表的应用程序运行情况进行了详细的解释,并讨论了如何通过线程ID来跟踪特定线程的状态。
526

被折叠的 条评论
为什么被折叠?



