|
If I have 15 UI threads where each of them depends of each other. (If one hang other will hang). What could be efficient way to find which hang first.
Thanks.
Alex
|
|
|
|
|
Are you calling locks in your code?
If so, are you calling the locks to synchronize access to a shared resource?
If so, consider using the following wrapper class that can automate the locking for you in a thread safe object orientated manner.
http://code.axter.com/ThreadSafeObject.h
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
There is only one question how to find which thread hang first. Bad solution is to monitor threads with high frequancy just call WaitForSingleObject or PostMessage to thread and get reply. Solution is bad because inefficient and inaccurate. There is very high possibilty that you detect second hanged thread instead of first (initiator of hang). So if you increase frequancy and make time out (in waitforsingleobject) shorter you basicly wasting CPU on detection. Imagine if number of threads grow to 100.
|
|
|
|
|
I don't know what you are doing with 15 UI threads, that ask for a deadlock??? Consider using worker threads and polling using a timer.
But if you really need that, you can always consider using a map, where a thread 'registers' itself before asking for a lock and 'removing' itself when the lock is aquired or released. You can use the value returned by the GetTickCount function as the key.
I also got the blogging virus..[^]
|
|
|
|
|
I mean lock when thread hang for some unimportant reason. Keep in mind that if thread(UI thread) hang you are not be able to continue recieving WM_TIMER.
I just need to know which of the thread in chain of the threads hanged first.
Example
A thread -> connected to B -> to C -> to D
If D hangs C hangs, than B than A
Plus you don't know how intensive those thread has been consuming CPU. What I mean you can't rely that A strarted first and D hanged last that's means that CPU time for A > B.
Thanks.
Alex
|
|
|
|
|
A thread doesn't 'hang' for some unimportant reason! Either you requested a lock that one thread didn't release for some reason (maybe deadlock), or you made a little error and one thread got stuck in a infinite loop consuming all CPU time.
I can't think about an other reason why a thread could 'hang'..
If a thread is 'hanging' because it is waiting for a lock, you know where the thread is going to hang. If you just log some messages when a thread is going to request a lock and when a thread is releasing the lock, than you know which thread hangs first. All you have to do is figure out a way so that the program also 'knows' which thread hangs first.
This isn't a concrete code solution, but since I don't know exactly what you are trying to achieve, I can't give you one.
I also got the blogging virus..[^]
|
|
|
|
|
You know what is funny part. This is not my thread this is third party component. For me is not important why something happend with component what I need to do. I need to detect which hang first and kill it. If kill inocent thread which part of the chain it will be bad. Thats why I need to know which thread is hang first. I have wrapper thread around component which communicates with componet. So if my wrapper hand I need to kill it. Problem is that other wrapper thread connected to each other. So since one componet hung all my wrapper thread hang. I have some solution which is not so elegant.
Create global map key: thread ID value cpu tick count.
Than put in the wrapper thread waitforsingleobject with timeout 1 s.
After waitforsingleobject call GetTickCount and save value in the map.
After some threads hang I will find IDs of hung threads and find which of them has minimal CPU count. Which means that tread was polled last. I need to play with timing. But that waht I have now.
Thanks a lot anyway.
Alex
|
|
|
|
|
i have three classes A,B,C of which B and C derives from A.Now all three clases have their threads running independently i.e they are peer threads . Now what is the best way to synchronize such that inter-process comunication happens takes place .I mean should i use mutex or shared memory for inter process communication .
hitherto shall thou come but not further thee
|
|
|
|
|
Exactly what type of communication do you need to perform?
Can you give an example?
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
path: .\Samples\C++\DirectShow
this folder is essential,but the sdk I installed doesn't have?
|
|
|
|
|
CScrollView is a derived class of MFC supporting scroll.When size of document is bigger than size ofviewport,CScrollView will display scroll automatially.
How can Hide the scrollbar(s) and i can still scroll the view by such as mousewheel events in this case.
Is there any derived class of Cview to complete the same function(supporting scroll but not showing the scrollbar).
|
|
|
|
|
Why in the world would you want to contradict standard Windows usability and provide scrolling without a scrollbar? Why would your users want to re-learn how to scroll, just for your application? Then, have to deal with different mouse gestures as they switch between your applications and all other Windows applications?
What happens if your users don't have mouse with a scroll wheel?
CScrollView-derived views cannot simply have their scroll bars "hidden"; they are integral to the window. You would probably have to override the non-client size calculations and drawing.
PeterRitchie.com
|
|
|
|
|
In fact, i want to own a style like ACDsee viewer, users can move the content by drag mouse, but not by scroll the scrollbars. In my derived class of CScrollView, i have complete for it, but i cann't get rid of the scrollbars, it ocuppy the area of use's content.
|
|
|
|
|
Then just use CView and handle all the scrolling yourself.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Is there any derived class from CView in existence?
|
|
|
|
|
CView is derived from CWnd and is the base class of CScrollView and CCtrlView. Since what you are asking for is non-standard behaviour I doubt there is a readily available class that does what you want, but there might be if you search long and hard enough. You said you had it working with CScrollView, just the scroll bars were giving you trouble. It shouldn't be too difficult to derive a class from CView that does what you want. Just take the parts from CScrollView that you can use, and ignore or modify the parts you can't use.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Mfc is fine and all...but was just wondering. Is any method similiar to lets say c#'s way of doing things.
|
|
|
|
|
i don'tknow about C#, but what about creating a new dialog ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I created a MFC Regular Shared DLL. This dll is working perfectly with VC application, but i want to access this DLL in VB application, What changes require in my dll for working in VB
pls tell me
Manoj
|
|
|
|
|
Hi,
I have a ListView in which I have used WM_NCCALCSIZE to give me an area at the top where I can draw my own info (above the header). This is fine except that it messes up the vertical scrolling. The last list item (in report view) doesn't appear. (My additional NC area is about 18 pixels high, which is about the height of one item.)
It seems that the ListView still thinks its client area is the original size, and so does not allow scrolling down as far as the last line. I have tried using SetScrollInfo to increase its max scroll point, and this works in that I can click down and see the last line appear, but on releasing the mouse, it jumps back up a line, and reverts to the original scroll-bar behaviour.
Does anyone have any ideas on how I can fix this? (If I apply the same code to other types of control they work fine, it's just listviews that don't.)
Thanks,
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Just a wild guess here. Could it be that the list view expects to only have a CHeaderCtrl at the top, and adjusts its scrolling only based on the header control. How about making the CHeaderCtrl ownerdraw and adding the extra space to the header instead of the list control itself?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I think it must be something to do with that, though turning off the header doesn't make it any better.
You can try it easily by subclassing a ListView control, then handling WM_NCCALCSIZE and adding something like
lpncsp->rgrc[0].top += 20;
Now, add a load of items to the list, and you will see that the vertical scroll-bar doesn't allow you to scroll right to the bottom of the client area. The bottom items get clipped.
I can't find any way of telling the ListView how big to consider its client area to be.
The closest I have to a solution is to fiddle the scroll bars on scrolling:
SCROLLINFO si = { sizeof(si), SIF_RANGE };
m_pList->GetScrollInfo(SB_VERT, &si);
si.nMax = m_pList->SendMessage(LVM_GETITEMCOUNT);
m_pList->SetScrollInfo(SB_VERT, &si);
This allows me to scroll to the bottom, and shows me the bottom item when scrolling, but on releasing the mouse button it jumps back up one notch.
I know you like a challenge, and will no doubt find me a solution!
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Can anyone help me out please. I have been searching the internet for ages now trying to find a decent tutorial about this topic. If you know where there is one please paste it here
|
|
|
|
|
In Win32 Api!
WM_SETFONT
In MFC
CWnd::SetFont
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|