 |
 | My vote of 2 Sarath. | 8:56 5 Mar '09 |
|
 |
Duplicated. It's there in MSDN itself
|
|
|
|
 |
 | I'm having a "Fifth Element" moment here... AndreyT | 12:56 4 Apr '08 |
|
 |
Remember, when Zorg was walking out of the room after giving a crate of ZF-1 guns to the Mangalores, he said that "a real killer, when he picked up the ZF-1, would've immediately asked about the little red button on the bottom of the gun"?
Same with this code. A real programmer, seeing this code, would immediately ask the obvious question: who is supposed to maintain ownership of the memory occupied by the name? Is the caller responsible of keeping the original memory area alive as long as the thread is executing? Or does the thread copy the name into its own memory, meaning that the caller's memory can be safely released?
For some reason, none of the articles about this trick mention this indescribably important detail. So, here's the answer for you: the name is copied to the thread memory, so it is OK to release/reuse the original memory.
|
|
|
|
 |
 | Nice article ThatsAlok | 20:57 25 Jul '07 |
|
 |
This funtion is boon for person debugging multi threaded application!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow cheers, Alok Gupta VC Forum Q&A :- I/ IVSupport CRY- Child Relief
|
|
|
|
 |
 | how i can have optional number of threads?? kamelian_20 | 23:08 14 Mar '07 |
|
 |
hi all
i want to know how i can have optional number of threads.i mean the user of the program needs to have some specified thread to do his work but for programmer it is not specified so the program should have this ability to get number of thread from user.how it could Implement?
thanks.
regard
|
|
|
|
 |
 | Here is a hint ndl | 8:04 19 Apr '06 |
|
 |
This didnt work when I first tried it in vc6. Originally, I Called
HANDLE th = (HANDLE)_beginthreadex(NULL,NULL,MyThreadProc,param,&threadid); SetThreadName(threadid,"MyThread");
To make it work, call SetThreadName like this from inside the thread.
unsigned int __stdcall MyThreadProc(void *param) { SetThreadName(GetCurrentThreadId(),"MyThread"); ...
Note that in VC6 the threadname is truncated at 9 characters.
Neil
|
|
|
|
 |
 | Attaching to Process robma | 12:22 3 Nov '05 |
|
 |
This only seems to work if you are in the debugger at the time SetThreadName is called. What if you are Attaching to a Process late which is done if you are debugging a running service that has deadlocked? Does anyone have a solution that works even if you attach to the process late?
|
|
|
|
 |
|
 |
No idea how this should work. You have no influence to the debugger through your programm if it is dead locked and you attach the debugger late.
Maybe you can set the thread names periodicaly so you can attach the debugger when the service is running but before it locks.
(Best Regards,) Patrick Hoffmann
-- modified at 18:39 Thursday 3rd November, 2005
|
|
|
|
 |
 | Thanks Patrick Michael Holm | 3:04 13 Oct '04 |
|
 |
I didn't see this on MSDN so it's very helpful to me and probably others also. Ignore the negative feedback.
|
|
|
|
 |
|
 |
Agreed a very useful post. It isn't possible to see everything there is to see on MSDN.
Now if there was some way to get the threads that we don't create to name themselves I'd be in programmer heaven.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
 |
 | Why repeating the MSDN !? Jochen Kalmbach | 1:42 13 Oct '04 |
|
|
 |
|
 |
Sorry I didn't know that. I got it from google groups and found it helpful and missed it in this forum.
So blame on me!
(Best Regards,) Patrick Hoffmann
|
|
|
|
 |
|
 |
The article linked above states that it is for .NET. Will it work in VC++6 as well?
|
|
|
|
 |
|
 |
Try it out! Official documented is it only in VC7 and later.
Greetings Jochen
|
|
|
|
 |
|
|
 |
|
 |
It works in VC6, but I can only get it to display the first 9 characters. Does anyone know if this is an actual limitation, or is there a way around it?
|
|
|
|
 |
|
 |
Yes, this is a limitation of VC6.
|
|
|
|
 |