|
The situation is that, I have created a worker thread that loads a COM dll and calls one of it function. The function is a blocking function.
Now I want to suspend/resume or termiante the worker thread while it is blocked in the function call.
I am using CreateThread and have tried TermiateThread, SuspendThread and ResumeThread but they seem to only execute after the thread has returned from the function call.
Is there a way to manage this blocked thread.
|
|
|
|
|
Hello,
When the function of the COM object blocks, your thread becomes blocked to. Suspending the thread has no effect in the sense that the object is already in a form of suspended. the effect that it has, is that the executing of the called function will be suspended until you resume again.
Your thread should terminate...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
omairaftab wrote: TermiateThread
I am surprised that this does not work. Sure of that ?
~RaGE();
|
|
|
|
|
In general you should not use SuspendThread or TerminateThread . They are meant for debuggers and can not be used safely (in almost most cases) in other contexts. The reason is that when you suspend a thread it could be holding a lock which can result in dead locks. But don't take my word for it, see here[^].
The moral of the story:
Don't use the SuspendThread or TerminateThread - You'll just make horrible, hard to reproduce and hard to debug multithreaded dead lock problems for yourself.
Steve
|
|
|
|
|
Hi Guys,
First of all i really thank to all as i got all the answers to my doubts.
This time i have some interesting problem. In my projects thre are more than 300 classes. But in the class view it's only showing 1 class. Another interesting the same code when it was in the original directory its showing all the classes but when i placed the same code in a different folder it's showing only one class. My team mates are also facing the same problem. Please help me if you know the reason.
|
|
|
|
|
first delete the .clw and .ncb file and then open the project.
Regards
Anil
|
|
|
|
|
BiswaR wrote: My team mates are also facing the same problem. Please help me if you know the reason.
First Close down the Project, delete PROJECTNAME.clw, ProjectNAme.ncb (which contain the data about the CLassView and File View), now when ever open you project again you will able to see Classes and other related things
"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/ IV
|
|
|
|
|
How can I change the color of a tabctrl?
When I overwrite OnCtlColor and use SetBkColor it does not work.
When I use OnEraseBkgnd and some "FillSolidRect" on the client rectangle it also does not work.
|
|
|
|
|
You need to WM_PAINT in the class CmyTabCtrl
class CmyTabCtrl : public CTabCtrl
{
// Construction
public:
CmyTabCtrl();
virtual ~CmyTabCtrl();
DECLARE_MESSAGE_MAP()
public:
//{{AFX_MSG(CmyTabCtrl)
afx_msg void OnPaint();
//}}AFX_MSG
};
|
|
|
|
|
Thanks for the hint, basically it works - but if do some getclientrect and fillsolidrect, the second of my two tabs is no longer seen and the borders of the tab are gone.
|
|
|
|
|
Hi all,
I have a problem about getting CPU Usage of each CPU for a process running on multi CPUs system.
Currently, I only can get total CPU usage. My application is required to calculate CPU Usage of each CPU.
Anyone know about this topic, Could you please help? Thanks very much
Tin Le
|
|
|
|
|
Dear friends,
I use CListBox and events(Click,dbclick,....)
But event LVN_KEYDOWN is't work exactly.the keys left and right(keyboard) not work exactly
if we are 10 element in the list,Now if press key right value is not
and again pree key right value is 0
Thank you for answer
|
|
|
|
|
NoxMan wrote: I use CListBox and events(Click,dbclick,....)
Is it CListCtrl .
Owner drawn
Jesus Loves
|
|
|
|
|
|
Hello. I have the following question.
I have an array of floating-point values and I want to sum them all. Does the accuracy of result depend on the order in which I sum them? Should I sort this array for best accuracy?
I'll be grateful for any help
Dmitry
|
|
|
|
|
Technically, you should sum the values from smallest to largest (in magnitude, -1000.0 is larger than 0.1). In practice, it really only makes a difference if your numbers have an large range (no, I'm not going to define 'large' - it depends on your data).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you for reply!
Can you explain in a few words, why it is so? (why should I
sum from smallest to largest)?
Dmitry
|
|
|
|
|
Floating point variables only have a limited amount of precision. They can represent very large and very small numbers, but if they represent a very large number, they can't keep track of all the decimal places. A double has about 15 digits of precision, but can represent numbers up to about 10308.
Say you're adding two numbers, 100000000000000.0 and 0.000001. The answer is obviously 100000000000000.000001. However, a double type only has 15 digits of precision, so it rounds this to 100000000000000. Even if you add 0.000001 to this number a billion times, you'll still get the same result - the intermediate results are rounded down because the double type can't support enough digits of precision.
The solution is to add the numbers from smallest to largest - so that you're always adding together numbers that have similar numbers of digits. This way the double type is not required to have large numbers of digits of precision. Therefore, your results do not lose as much precision, and the result is more accurate.
Technically, you can go even better than summing smallest to largest. The most accurate solution is actually to sum the results in a sort of tree structure, where you sum each pair of adjacent values and store the intermediate results, then go back and sum the adjacent pairs of intermediate results, until you get to a single result at the end:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3 7 11 15 19 23 27 31
10 26 42 58
36 100
136 This will give you the absolute greatest accuracy possible, but the effort is not worth the complexity in the calculation unless you absolutely need the accuracy. Summing smallest to largest is usually the best solution.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
In VC++ How to read the data directly from file into CSring object.
anil
|
|
|
|
|
use CStdioFile mfc class
"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/ IV
|
|
|
|
|
Dear friends,
we have Install mac os on PearPC. we have create 6GB hard disk image.
During Installation, we are getting error" unable to install bundle
software on this computer".I think this error is due to 6 GB hard disk
image. so pls suggest any proper solution to us, so we are able to solve
our problem. also suggest any forums related to this issue, so i will
post my query on this forums.
I know this is not related to Mac Os forum. But if you know soln of this
problem , give me a reply.
Regards
kedar
Girish
Software Developer
|
|
|
|
|
vcforums wrote: know this is not related to Mac Os forum. But if you know soln of this problem , give me a reply.
I believe, you will get better answer at MAC forums.. as user here are more Familiar wityh Windows Os only
"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/ IV
|
|
|
|
|
Dear All
I want to write a dialog based application where user is prompted to choose some file using CFileDialog. I have to open the file selected by the user with default Shell editor associated
with that file from my application ( For e.g, if user selecets "Sample.bmp", i must be able to
run "mspaint.exe" application with "sample.bmp" opened for editing from my application ) and i must not allow user not to do any operation with my application till he closes the opened application.
Can somebody help me in implementing this functionality.
Thanks in advance
Regards
Krishna
|
|
|
|
|
Hi,
you can use ShellExecuteEx() and the use the handle to the created process returned by it to check its existence.
Bye,
Cool Ju
Dream Ur Destiny
-- modified at 4:07 Friday 10th February, 2006
|
|
|
|