|
After modifying the code like this,
DWORD dwLastTickCount = ::GetTickCount();
DWORD dwWaitResult = WaitForSingleObject(m_MonitorEvent, INFINITE);
TRACE("dwWaitResult(%d)",dwWaitResult);
// print return value from WaitForSingleObject
switch (dwWaitResult)
{
case WAIT_OBJECT_0://Do the work
ResetEvent(m_MonitorEvent);
break;
default
break;
}
TRACE("Time of the job in ms: %d\n",::GetTickCount()-dwLastTickCount);
dwLastTickCount = ::GetTickCount();
my debug output is
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 16
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 0
dwWaitResult(0)Time of the job in ms: 15
|
|
|
|
|
Everything looks fine. What is the CPU usage now? If still 100% how often do you triger m_MonitorEvent ? Try to comment out SetEvent(m_MonitorEvent) line and check the CPU usage again.
|
|
|
|
|
If comment out the line SetEvent(m_MonitorEvent), CPU usage is not 100%. Monitor event gets triggered very very fast. One thraed reads data from file which has say minimum 10,000 records, it reads each line, and triggers Monitor event which displays the line on UI. Hence as soon as a line is read from file, Moinitor event gets triggered. So I can say monitor event gets triggered 10,000 times if 10,000 lines are there in the file. During this raeding and displaying operation CPU usage is shown as 100%, after the reading of file is over, it is not 100%.
Can you please let me know how to proceed further?
Thanks
Madhavi
|
|
|
|
|
Could you post your source code? I will have look at it.
|
|
|
|
|
Can you please give me your email id so that I can post the code.
Thanks
madhavi
|
|
|
|
|
|
ok thanks.. i have sent the code
|
|
|
|
|
It's not unusual for the CPU to go to 100% for an intensive operation like reading every line from a file and updating the UI for every line of text. If the CPU usage drops back to normal levels after the file is processed, I would think your code is fine.
The only change I would make is to perhaps consider resetting the event REGARDLESS of the result of the wait operation. As long as it is not critical that EVERY line get updated to the display, because under normal circumstanes, you are not going to get WAIT_FAILED. You will probably never see WAIT_TIMEOUT since you specified INFINITE.
|
|
|
|
|
Hi
I have created a simple vb .net dll and tested it, it's working fine. My problem is, i would like to call that dll in a console c++ application but i dont know how to go about doing that. Please help me. Thank you in advance.
|
|
|
|
|
hi,
first u register the dll using regasm utility.
regasm "yourdll.dll";
it will create registry entry .[u can import type library
using tlbimp.exe ]
u can use this dll in by
#import "yourdll.dll"
by
baijumax
|
|
|
|
|
Hi all,
I've a problem about reading a file. I opened the file using CFile. when I asked for the size of file using CFile::GetLength() it's returing zero. Please help me for the solution.
Code here
-----
CFile pFile;
CFileException e;
if(!pFile.Open("img_1.bmp", CFile::modeRead | CFile::shareDenyWrite, &e))
{
printf("\n Error in opening File\n");
exit(1);
}
DWORD dwStart = pFile->GetPosition();
DWORD dwBitsSize = pFile->GetLength();
printf("\n Size %d\n", dwBitsSize);
BITMAPFILEHEADER fileHeader;
memset(&fileHeader, 0, sizeof(fileHeader));
UINT count = pFile->Read(&fileHeader, sizeof(fileHeader));
printf("\nByte Read %d %d\n", count, pFile->GetPosition());
----
Byte read and the current positon also give me the 'zero' values.
Thanks in Advance
Ardhendu
|
|
|
|
|
here the member access operator is "."
pFile.Open("img_1.bmp", CFile::modeRead | CFile::shareDenyWrite, &e)
and here the member access operator is "->"
pFile->Read(&fileHeader, sizeof(fileHeader));
There is no spoon.
mail
|
|
|
|
|
Sorry, I gave only the pseudo code. Actually the CFile is passed to another funtion. It like:
BOOL GetBitsValue(CFile *pFile)
{
DWORD dwStart = pFile->GetPosition();
DWORD dwBitsSize = pFile->GetLength();
printf("\n Size %d\n", dwBitsSize);
BITMAPFILEHEADER fileHeader;
memset(&fileHeader, 0, sizeof(fileHeader));
UINT count = pFile->Read(&fileHeader, sizeof(fileHeader));
printf("\nByte Read %d %d\n", count, pFile->GetPosition());
}
Even If I check after opening the file in the same function it returns zero. Its like:
---
DWORD dwStart = pFile.GetPosition();
DWORD dwBitsSize = pFile.GetLength();
printf("\n Size %d\n", dwBitsSize);
BITMAPFILEHEADER fileHeader;
memset(&fileHeader, 0, sizeof(fileHeader));
UINT count = pFile.Read(&fileHeader, sizeof(fileHeader));
printf("\nByte Read %d %d\n", count, pFile.GetPosition());
---
Thanks,
Ardhendu
|
|
|
|
|
Cannot see anything wrong with your code.
btw from wot kind of application are you trying to run this code.
There is no spoon.
mail
|
|
|
|
|
Have you tried entering the fully qualified path for the filename e.g. "c:\\graphics\\img_1.bmp" ?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I printed the full path using pFile.GetFilePath(), it's giving me the full path (correct) of the file.
|
|
|
|
|
Um, Sorry I can not see anything wrong with what you are attempting to do. GetLength should return the size in bytes of the opened file in question.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
It is hard for us to help you, if you do not tell us whether there is an error when you use CFile::Read(...).
DWORD dwStart = pFile->GetPosition();
DWORD dwBitsSize = pFile->GetLength();
printf("\n Size %d\n", dwBitsSize);
BITMAPFILEHEADER fileHeader;
memset(&fileHeader, 0, sizeof(fileHeader));
TRY
{
UINT count = pFile->Read(&fileHeader, sizeof(fileHeader));
printf("\nByte Read %d %d\n", count, pFile->GetPosition());
}
CATCH(CFileException, e)
{
printf("\nCFileException %d\n", e->m_cause);
}
END_CATCH
|
|
|
|
|
In the calls to printf() , what happens if you change %d to %lu ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi there,
can anyone tell me how to stop a link opening in a new window and just use the existing window??
For example: I've got a little explorer app(MFC) with 2 windows. The left side displays the C:/drive
and the right side displays a FTP address. The left window navigates fine, but the right side insists on opening
a new explorer window when I click on a link, instead of changing inside its own window. When the ne window opens... that navigates fine... just the way I want the right side widow to.
Its probably something stupid, knowing me... definately something stupid But I've tried a bunch of stuff for the last
24 hours now and nothing stops it opening in a new window!
Help!
Henry F
|
|
|
|
|
If I understand you correctly, the right pane is actually an HtmlView displaying a web page. In any case, to redirect a link to a specific window you have to use the "target" property. For example:
// somewhere in an HTML file
<a href="http://www.website.com" target="_self">Click here</a>
"target" accepts any of the following:
_blank, which opens the link in a new window
_self, which opens the link in the current window
_parent, which opens the link in the parent window
_top, which opens the link in the top most window
Hope this helps.
|
|
|
|
|
Thanks for the reply man, but(as usual) its not the HTML I need to change.
Basically its an Explorer Window displaying content on a server via FTP:
Naviagte2(_T(ftp://whatever.com),NULL,NULL)
It displays fine but when I want to open a folder - it launches a new explorer window outside the application and displays the info in that window.
Is there some way of controlling this so that all clicked links open inside the application only?
thanks
|
|
|
|
|
handle OnBeforeNavigate2, cancel the navigation if it's to another window, and navigate to the url just cancelled... something like that.
|
|
|
|
|
Clever idea!
Any chance you could scribble the code down? I'll buy u a cup of tea
|
|
|
|
|
I have an important CStatic text-lable in my CDialog class.
How may I change the font and color of the text in a simple way?
_____________________________
...and justice for all
APe
|
|
|
|