|
Hi All,
I am working on a telecom project.
I am facing CPU 100% problem.
Can any one tell me different reasons for a system CPU to reach 100%. I am reading a telephon number from a text file after that dialing the same number. After successfully done I am deleting the text file and updating the counter in DataBase (SQL). All these operations are done within a thread. The Application is a multithreaded application. I am not able to trace why the system CPU is reaching 100%.
OS is Windows NT.
Waiting for your suggestion(s).
Thanks in Advance.
Kumar.
|
|
|
|
|
In multithreaded programming, you must be careful not to monopolize the CPU. The OS of course looks after scheduling, but it's up to you to let the OS know that you don't need every available timeslice for your loop.
A simple thing to do is to Sleep() your thread for a reasonable period of time between checks to see if it has work to do.
As a simple test, try putting Sleep(500) somewhere inside your loop and see what kind of effect it has on your CPU usage. You likely should architect a more elegant solution than a simple Sleep() call, one that better matches your program logic, but this should get you started.
You should also check out WaitForSingleObject() and its cohorts, it may make sense for your app.
|
|
|
|
|
If the application is multithreaded, I would guess that one of the threads is spinning in a while loop, possibly waiting for something to happen. With a thread procedure like:
while(1)
{
WaitForSingleObject(..., 0) <- zero timeout
}
You can get 100% CPU utilization in a thread.
Changing the timeout to 1 millisecond will fix this.
Another possibility is that a thread in the database driver is using 100% of CPU time or something is polling and wating for the phone to connect. Hope this helps
Peter
|
|
|
|
|
I try and create a thread that will loop the GetMessage,TranslateMessage,DispatchMessage commands,
but the thread only executes the loop once, and then exits. Someone told me you have to create a "GUI
thread" to do that. How to you make a GUI thread then?
--Dave
|
|
|
|
|
As fas as I know,
GUI thead is a thread that has a message pump..
No more than that..
So check your callback procedure of the thread...
Make sure you do not break the loop of message pump..
It will be broken automatically by WM_QUIT..
After testing this, give me a THREAD to this posting..
Regardz
-Ryan
|
|
|
|
|
Hello there,
I have created a treeview that reads the local drives using GetLogicalDrives() method....
However, I would like to make this treeview capable of reading UNC type of paths.
I have tried a few different things, but none of them seem to be working. I would appreciate your feedback.
thanks
|
|
|
|
|
Hi,
Right now I am using GDI function CreateDC("DISPLAY", NULL, NULL, NULL) to capture the screen (desktop). However, it's too slow. I am
thinking there must be a way in DirectDraw to do this. I tried with IDirectDraw7::GetGDISurface(), but was not successful. To my best understanding, desktop surface exists in video memory somewhere but I don't know how to access it. Do you know if it's possible at all to capture this surface with DirectDraw, particularly with
IDirectDraw7::CreateSurface()?
Thank you very much for your time!
kk9
|
|
|
|
|
Hi,
I got a printing class and each time when a page finish printing the printer alway advances automatically to the next page.
I love to find some command to stop this advance (just for special purpose)
I am using
//my code here
CDC *ptrdc;
......
ptrdc->StartDoc (&doc);
ptrdc->StartPage();
.......
ptrdc->EndPage(); // I thougt this command will stop!!
ptrdc->EndDoc();
.......
Thank you,
Brian
|
|
|
|
|
Is there anyway to tell Visual C++ IDE to automatically use Macro assembler to compile assembly language files instead of using a custom build every time a assembly file is included in a project?
|
|
|
|
|
Hi,
Does any body have experience with writing a program that runs multiple jobs scheduled at different time? I would like to get some ideas of writing an efficient scheduler type of service. My first approach is to set up the schedule in a database table. A main thread will loop through the table and create new thread for the job that is due to run. Once the job is done, the thread will be terminated. My main concern is that if the table gets too big with a lot of jobs, the jobs would not get processed at the right time. Can somebody verify this design and share some of his expertise on this type of program? Thanks.
Wilson
|
|
|
|
|
How can I acces to voriables of other program?
|
|
|
|
|
The easiest way, assuming you're writing both, is to use SendMessage to pass the variables as a string between them.
|
|
|
|
|
How can I acces to voriables of other program?
|
|
|
|
|
How do one programmatically set the various user privileges such as - SeTcbPrivilege, SeChangeNotifyPrivilege etc.?
Is the API for this provided in:
"Windows Management Instrumentation" (WMI) ??
Many thanks to all those who respond.
Sai
|
|
|
|
|
Hi all,
If anybody has used a, "MS Tabbed Dialog Ctrl 6" in their VC++ 6.0 projects, pl. let me know the procedure to doit!
Im not able to add the tab pages in design time (or runtime). Though I get the wrapper class, there are no methods in it to add page.
thanks in advance..
please reply in mail to prabhahar@flashmail.com
|
|
|
|
|
Hi Buddy,
During design time of the control, you will have to change the "TabsPerRow" property to the desired no of tabs per row and then change the no of tabs (ie tab count) property.
Though i didnt go through the class wrapper, i guess the above procedure has to be followed in runtime also.
Happy coding.
Cheers
KayKay
|
|
|
|
|
Though "TabsPerRow" property can be changed in design time, the control doesnot display the tabs ( design-time) so that I can place the controls on it.
Nor it does allow me to add a PropertyPage (or a dialog) in the runtime. Therez no method in the wrapper class, to add the pages. The documentation is available only for VB and not for VC++ 6
Any help reg. this issue is welcome.
Thanks
|
|
|
|
|
Hello,
I found a contribution in this web site about multilanguage applications for Windows NT and Windows 2000 under the title Multilanguage Application - Change Application Language by Daniel Zuppinger under MFC/STL path.
My question is how I could proceed for Windows 95/98?
I like to know how a second or third language is added in the string table or how a second or third language is added to the dialog forms. The tutorials and text books don't cover this topic.
How can the language be chosen or set at compile time and/or at run time ?
Thanks for any help.
|
|
|
|
|
Hi,
I need to sort data in List Ctrl (report view) when user clicks on any of the column headers. Ascending and descending on alternate clicks.
Plz help.
|
|
|
|
|
Hi, try to look throw this functions
void CMListCtrl::DoSort()
{
SortItems((PFNLVCOMPARE)MySort,(LPARAM)this);
}
BEGIN_MESSAGE_MAP(CMListCtrl, CListCtrl)
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnclick)
END_MESSAGE_MAP()
void CMListCtrl::OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLISTVIEW* pNMListView = (NMLISTVIEW*)pNMHDR;
int iColumn = pNMListView->iSubItem + 1;
int iColumnLast = m_iSortedCol;
if (iColumn == abs(iColumnLast))
{
iColumn = -iColumnLast;
}
m_iSortedCol = iColumn;
DoSort();
}
/*
The comparison function must return a negative value
if the first item should precede the second, a positive
value if the first item should follow the second, or
zero if the two items are equivalent.*/
static int CALLBACK CMListCtrl::MySort(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CMListCtrl* _this = (CMListCtrl*)lParamSort;
CFileItem* pFIOne = (CFileItem *)lParam1; // was added using Insert
CFileItem* pFITwo = (CFileItem *)lParam2; // was added using Insert
return 0;
}
|
|
|
|
|
How do I create a list box on my main window using MFC? I know how to do it for a DialogBox, but can't figure out how to do it on the main window.
|
|
|
|
|
Derive your view from CFormView and then you can make your view any combination of dialog items.
OF course if you want to keep your view as it is but only add the one item, then you'll need to create a frameless dialog to simulate an item in the view itself.
|
|
|
|
|
helo all,
i have a small question. i am developing a commercial app using directx and internet explorer component. We have been thru the EULA of both (which seems to be in latin).
The question is that "is it legal to distribute downloaded copies of directx and IE installables ?". Both, as is well known are freely avialable for download.
please mail me ur replies off-line !
Mayuresh Kadu
mskadu@hotmail.com
|
|
|
|
|
Hi,
I have a dialog with an RTF formatted text.
Right now it only supports English. How do I detect a diffetent character set, and set it accordingly?
I also may have to swtich right-left reading if it's a right to left oriented language, how do I switch in the directions back and forth?
I have read some of the RTF documentation, but couldn't get the whole thing to work right.
Thank you,
|
|
|
|
|
Anybody!! Help me. I need algorhtim to use anti-aliasing drawing for simple figure.
|
|
|
|