|
No, I don't have to. Still, these forums are to share knowledge so I make an effort to be helpful if I can. This entails both telling people what and what not to do.
Steve
|
|
|
|
|
Stephen Hewitt wrote: No, I don't have to. Still, these forums are to share knowledge so I make an effort to be helpful if I can
Very good.
Stephen Hewitt wrote: This entails both telling people what and what not to do.
Not so good, I prefer the following:
This entails telling people about your opinion on both what and what not to do.
Cheers
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: Not so good, I prefer the following:
This entails telling people about your opinion on both what and what not to do.
Whose opinion would I tell other than my own?
Anyway, have you tried the program I posted yet? I am curious to see if that changes you mind.
Steve
|
|
|
|
|
Stephen Hewitt wrote: Whose opinion would I tell other than my own?
As stated, it appeared a bit axiomatic.
Stephen Hewitt wrote: Anyway, have you tried the program I posted yet? I am curious to see if that changes you mind.
Not I don't, but of course I will. And you will know about.
I wondering if OP expected such a long debate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: I wondering if OP expected such a long debate.
He'll live
Steve
|
|
|
|
|
I just tried (as promised) your sample code. Indeed it's impressive: it hangs after few (overall) iterations. Observations:
(1) Yes, it is extreme: the two threads are doing heap memory allocation/deallocation concurrently (and nothing else).
(2) The code proposed in OP already hangs (that was the problem to solve).
Bottom line: I still think that you can use TerminateThread as last resource, provided the main thread waits for secondary thread expiration without doing anything else (oh yes it can sleep for a while!)
Cheers
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
CPallini wrote: (1) Yes, it is extreme: the two threads are doing heap memory allocation/deallocation concurrently (and nothing else).
No, it isn't extreme. Allocating memory is something almost every thread will do. If the thread is terminated while it holds the heap lock all memory allocation will fail in the whole process. All I've done is stripped down the code to a bare minimum. In a more realistic situation it's worse: the terminate will work sometimes then, for no apparent reason, all memory allocation will mysteriously fail and result in a deadlock. Try tracking something like that down: the point at which the deadlock occurs is far removed from the source (in fact in a different and long dead thread). Memory allocation isn’t the only example of this kind of thing: any function that uses critical sections – such as many of the Win32 API calls – will exhibit the same problem.
In short: calling TerminateThread is reckless and dangerous and almost never safe. After calling TerminateThread the process is in an unknown and possibly invalid state. You can not make quality software like this.
Steve
|
|
|
|
|
Stephen Hewitt wrote: In short: calling TerminateThread is reckless and dangerous and almost never safe. After calling TerminateThread the process is in an unknown and possibly invalid state.
In short (IMHO): calling TerminateThread maybe the last option in situation like the ont the OP depicted (unless you can change the overall design the way you suggested).
Stephen Hewitt wrote: You can not make quality software like this.
I agree on the above.
Cheers.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Don't use TerminateThread . See here[^] for why not.
Steve
|
|
|
|
|
Thanks steve, lots of points to be noted. Also nice that there's .net illustration too. Reading them. Thanks
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Dear All;
I am hosting a microsoft web browser control (assuming it has got a variable: m_webBrowser) on a dialog box.
I want to capture a screen shot of the content of the web browser (excluding the main window).
Does anyone know or have any idea how to save the content of web browser as an image?
I have tried this:
<br />
RECT rc;<br />
HWND hWnd = m_webBrowser.GetSafeHwnd();<br />
::GetWindowRect (hWnd,&rc); <br />
HDC hDC = ::GetDC(0);<br />
HDC memDC = ::CreateCompatibleDC ( hDC );<br />
HBITMAP memBM = ::CreateCompatibleBitmap ( hDC, rc.right-rc.left, rc.bottom-rc.top );<br />
::SelectObject ( memDC, memBM );<br />
::BitBlt( memDC, 0, 0, rc.right-rc.left, rc.bottom-rc.top , hDC, rc.left, rc.top , SRCCOPY );<br />
But it only saves the visible area of the web browser and not all the content !!!
I will be very gratefull if anyone can help with this problem as it is giving me a real headache .
llp00na
|
|
|
|
|
|
I am indeed very gratefull,
Thank you very much
llp00na
|
|
|
|
|
Hi,
I am doing a fopen and fwrite,
TCHAR *szFileName = tmpnam(NULL);
FILE *pfBmpFile = fopen( szFileName, "wb" );
fwrite( lbbuddy_data, sizeof(unsigned char), __bmp_size, pfBmpFile );
fclose( pfBmpFile );
There is no problem when we create our application users as administrators on the workstation
but in this case they can not be Administrators because of security risks. So whenever i use a Non-Admin users the application crashes.
Does someone have suggestion on how to go about other than giving administrator access?
|
|
|
|
|
AnilUnni wrote: So whenever i use a Non-Admin users the application crashes.
Does someone have suggestion on how to go about other than giving administrator access?
it crashes ? you should check the return from fopen before using it in fwrite/fclose.
you'll probably have better luck if you create your temp file in the system temp folder. use SHGetSpecialFolderLocation to get the path.
|
|
|
|
|
AnilUnni wrote: TCHAR *szFileName = tmpnam(NULL);
FILE *pfBmpFile = fopen( szFileName, "wb" );
Does tmpnam() return a path that non-administrators have access to?
AnilUnni wrote: ...the application crashes.
Where?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Does tmpnam() return a path that non-administrators have access to?
No it does not so should i create a file with a name?
|
|
|
|
|
AnilUnni wrote: ...should i create a file with a name?
Last time I checked, all files had names.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
No it doesn't that was the problem. Thanks Dave
|
|
|
|
|
if use GetOpenFileName() dialog , you can delete ,rename file or folder via right key menu, how can avoid it? i use C&API, or are there any component to use,like vb's ocx, a dialog have a directory tree box and a file list box ,but how can i invoke ocx?
Help!!!!
urgent!!!!!!!!!!!!!!!
|
|
|
|
|
zhongwenjia wrote: if use GetOpenFileName() dialog , you can delete ,rename file or folder via right key menu, how can avoid it? i use C&API
See the docs for the OPENFILENAME structure Flags member: "If you want the old-style user
interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook
procedure. If you want the old style but do not need a custom template or hook procedure, simply
provide a hook procedure that always returns FALSE."
The GetOpenFileName()[^] docs explain how to add the hookproc.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hey DavidCrow - is your link broken or is it just me?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: is your link broken or is it just me?
It's just you me!
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
WIN 32 application crashes while calling a MFC DLL export function, which creates a dialog box using CDialogBox::Create().
What will be the reason?
One more doubt..How can I add MFC support to a WIN 32 Aplication?
Thankx In Advance...
|
|
|
|