|
Read the whole thing again and you'll know may be you should grow up and not me.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
The follow-up question is actually very good and far more important (in my opinion) than the original question. It's probably a good idea to consider a redesign when you are handling so many messages - either they are superfluous or a different mechanism of communication is appropriate.
|
|
|
|
|
|
Hi Rahul,
I believe that the default message queue size is around 10000 messages and can be changed through the registry. It is possible although unlikely that you are exceeding this limit. As Rajesh pointed out you can check for this condition by checking the return value for ERROR_NOT_ENOUGH_QUOTA.
A more likely scenario would be that your thread is interacting with a UI object or modeless dialog and the thread message is being eaten. I would recommend that you check your thread code to make sure that you are not doing anything UI related. Never launch a modal dialog from a worker thread if you expect the thread to be able to recieve thread messages. Instead... have your worker thread post a message back to the main thread and allow that thread to create/manage dialogs.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks for the reply, I will check for that limitation also but I think I should not change it in registry.
|
|
|
|
|
Hi Experts,
I have a application (Sever and client) which used 2 port to communicate with client. But If i forcefully closes the client applicatiom, server application uses 99% cpy usage.
And I also checked all the recieving and sending threads, all are fine.
I could not figur it out.
|
|
|
|
|
And you think we will be able to figure it out without seeing anything of it? Please provide some code sniplets, preferably from the server. This does not mean the whole code.
Generally speaking:
You probably have a run-away thread (a thread that has a -possible- infinite loop that eats up the CPU). Try running your server with a debugger and when you see the high CPU usage, pause it and step trough the code to see what it does. If you see it running in circles, there you have it...
Try adding sleep(1) or such to let other threads breathe too.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
|
rahul.kulshreshtha wrote: If debugging is not possible then write into filesget another job
If he cant debug he shouldn't be writing code.
==============================
Nothing to say.
|
|
|
|
|
john5632 wrote: And I also checked all the recieving and sending threads, all are fine.
No they arent.
You have a server thread that is hogging the CPU when the client drops comms.
==============================
Nothing to say.
|
|
|
|
|
The most common cause of applications looping when communication closes is improper handling of the error returns from the various functions.
When you shutdown one end of a communications path the other end will recieve an error code or some other indication that the path is no longer functional. You are probably not handling those correctly. That's the first place I would look.
|
|
|
|
|
Hi,
I am using CMap. While adding and deleting elements I am using Locks because there are multiple threads Do I need to put lock before using pLookup function? Sometimes it crashes while looking up for an element. My lookup statement is like below :
if(cmap_buffer.PLookup(element.orderId) != NULL)
st_order = cmap_buffer[element.orderId];
Thanks,
Rahul Kulshreshtha
|
|
|
|
|
It is not thread safe. You will have to manually add the locking before accessing its data. Imagine what would happen if a node is removed while PLookup is using it.
The easies way of creating a thread safe container is to embed an existing container in a new class with the same interface, or a subset thereof if sufficient, forwarding all calls to the aggregated container and adding all the locking in between.
|
|
|
|
|
Thanks Niklas,
Using a thread-safe container will be a good solution. I wish Microsoft should provide some in-built thread-safe containers. As currently there is no inbuilt thread-safe way so I will go for creating my own. But I will not be able to use it in this project because it is 90% completed and implementing a new container and replacing it over existing map will take a big code-patching.
Thanks, I will take care this next time.
|
|
|
|
|
hi
i had created the menu.
i tried to add the image to the menu.
here is my sample code
CMenu menu;
CPoint point;
GetCursorPos(&point);
CBitmap Bmp_image,bmp1;
menu.CreatePopupMenu();
menu.AppendMenu(MF_STRING,ID__OPTION1,_T("Help"));
Bmp_image.LoadBitmap(IDR_bitmap1);
menu.SetMenuItemBitmaps(IDR_bitmap1,MF_BYCOMMAND,&Bmp_image,&Bmp_image);
reply it soon
thaks
best regards
sarfaraz
|
|
|
|
|
|
Your first parameter is wrong: see MSDN[^].
|
|
|
|
|
Hi,
Can anybody know about the fastest way to get folder size or the technique windows use to get folder size?
|
|
|
|
|
How about adding up the sizes of the files in that folder? I suspect a faster way would be to read the MFT but I don't know how to do that.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
|
This shows how to get the size of all the files in a folder,
and all its sub-folders on MS-Windows operating system.
It uses recursion to transverse all the directories, and return a 64-bit integer.
It was compiled with VC++ 2008 Express .
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;
__int64 TransverseDirectory(string path)
{
WIN32_FIND_DATA data;
__int64 size = 0;
string fname = path + "\\*.*";
HANDLE h = FindFirstFile(fname.c_str(),&data);
if(h != INVALID_HANDLE_VALUE)
{
do {
if( (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
if( strcmp(data.cFileName,".") != 0 &&strcmp(data.cFileName,"..") != 0)
{
fname = path + "\\" + data.cFileName;
size += TransverseDirectory(fname);
}
}
else
{
LARGE_INTEGER sz;
sz.LowPart = data.nFileSizeLow;
sz.HighPart = data.nFileSizeHigh;
size += sz.QuadPart;
}
}while( FindNextFile(h,&data) != 0);
FindClose(h);
}
return size;
}
int main(int argc, char* argv[])
{
__int64 size = 0;
string path;
size = TransverseDirectory("c:\\dvlp");
cout << "\n\nDirectory Size = " << size << "\n";
cin.ignore();
return 0;
}
|
|
|
|
|
Hi,
I am looking into the issue of code signing. We distibute our software on CD Only. It is NOT available as Download on the Internet. Our suite is definitely not intended for distribution amongst the masses.
Currently, None of our customers' computers are connected to the Internet, and most probably will not be so for the forseeable future. The code signing issue is coming up because of the demise of windows XP. We want to avoid all those security warnings that Windows 7 shouts when the signature is absent.
Now how is a Win7 computer which is not connected to the internet going to check that the signature in the code is valid. More to the point, what is the advantage for me to registering and paying for the Code signing certificate, if the receiving computers can never walk up the chain to verify the certificate. Furthermore, what do I do to stop my customers getting those Security warning dialogs when using Windows 7.
By way of explanation, the computers our software runs on, act as Cash Registers in small businesses. Users have no physical access to the machine itself. Most of our customers have One machine only, a small minority run Peer to Peer Lan's of two three or 4 terminals. (The maximum is 16).
The Software Core has ran on Win95, Win 98, Win Millenium, and Win XP, and we have NEVER had any security issues. Our system has also always ignored the Windows Security System. Each terminal always runs in Windows Administrator Mode.
Code Signing for this suite causes hassle, and in this circumstance I cannot see any benefit. Is there a way to switch it off altogether.
In general, the machines do not run much other software. a few have MS Office installed, but that's it.
I was thinking along the lines of including a SelfSigned Cert with the CD.
How do I get such Cert installed without security screams via Win7, from my Installation Program, also on CD.
Any observations on the subject are wellcome.
Kind Regards,
Bram van Kampen
|
|
|
|
|
I've got an app I'm trying to migrate to visual studio 2008. The app uses MDI child windows. Inside of each of these MDI windows, when it creates it child view, it's create a custom class derived from CFrameWnd, to allow the creation of a toolbar. In VC6 this worked perfectly. In VS 2008 the toolbar creation code doesn't return any errors, but it doesn't display the toolbar either. Have there been changes here that you need to do? Is there some new magic MFC incantation that's required? Should I advertise on Craigslist for virgins to sacrifice, or barring that, magical unicorns?
//edit
turned out the solution was adjusting the toolbar's CreateEx call, and *NOT* passing in a CRect(0,0,0,0) and (UINT)-1 for the last to parameters. Well at least that saves me the hassle of dealing with virgins...
modified 22-Sep-11 10:56am.
|
|
|
|
|
Dear Friends
I have a dataset like below. 1 means Straight line with startPointX,startPointY,endPointX,endPointY.
//////////////////////////////////////////////////////////////
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -178.200000 52.000000 -138.200000 52.000000
1 0.000000 24.600000 0.000000 19.000000
1 -125.421613 36.515000 -138.200000 52.000000
1 -123.421613 36.515000 -107.873000 36.515000
1 -100.000000 19.000000 0.000000 19.000000
1 -105.873000 36.515000 -94.557821 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -100.000000 19.000000 0.000000 19.000000
1 0.000000 19.000000 0.000000 24.600000
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -94.557821 36.515000 -105.873000 36.515000
1 -107.873000 36.515000 -123.421613 36.515000
1 -125.421613 36.515000 -138.200000 52.000000
1 -138.200000 52.000000 -178.200000 52.000000
1 -115.000000 0.000000 -115.000000 15.000000
1 -115.000000 15.000000 -100.000000 15.000000
1 -100.000000 15.000000 -100.000000 19.000000
1 -100.000000 19.000000 0.200000 19.000000
1 0.200000 19.000000 0.000000 19.000000
1 0.000000 19.000000 0.000000 24.574923
1 0.000000 24.574923 -0.000000 24.600000
1 0.000000 24.600000 -15.500000 28.575000
1 -15.500000 28.575000 -37.700000 28.575000
1 -37.700000 28.575000 -37.700000 36.515000
1 -37.700000 36.515000 -59.920000 36.515000
1 -59.920000 36.515000 -66.103821 36.515000
1 -66.103821 36.515000 -88.374000 36.515000
1 -88.374000 36.515000 -94.557821 36.515000
1 -94.557821 36.515000 -105.873000 36.515000
1 -105.873000 36.515000 -107.873000 36.515000
1 -107.873000 36.515000 -123.421613 36.515000
1 -123.421613 36.515000 -125.421613 36.515000
1 -125.421613 36.515000 -138.200000 52.000000
1 -138.200000 52.000000 -178.200000 52.000000
1 -178.200000 52.000000 -178.200000 52.500000
1 -178.200000 52.500000 -178.200000 55.000000
1 -178.200000 55.000000 -190.000000 55.000000
1 5.000000 0.000000 5.000000 55.000000
1 5.000000 55.000000 -190.000000 55.000000
//////////////////////////////////////////////////////////////
I have to construct a profile which I can easily do by making a GL_LINES.
After that I need rotate the profile by x-axis and construct a surface of revolution. Please giveme some idea how can I achieve this. I have done something but I am not getting the surface.
Like I am storing the original startPoints and endPoints in an array with assuming z=0.
Then rotating each point by x-axis. so x-values will be same and y and z values I am calculating using this formula.
y = y cosq - z sinq;
z = ysinq + zcosq;
Is this correct...?? Then I am defining a number of loops and in loop I am creating GL_QUADS for each startPoint and endPoint...
1st loop 1ststartPoint, 1stLoop 1stendPoint
2nd loop 1stStartPoint, 2nd loop 1stEndPoint...
But I am not getting any 3D surface. Please help me.........Check the code below.
//////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef struct point3D{
float x;
float y;
float z;
}POINT3D;
int count1;
POINT3D *startPoints, *endPoints;
void CRevolutionProjView::drawProfile(CString filename)
{
pFrame->m_wndStatusBar.SetPaneText(0,L"DrawProfile !!");
// profile to be drawn
GLfloat PI = 4 * atan(1.0);
//file needs be open
double startPX, startPY, endPX, endPY;
double cenX, cenY, cenZ, rad, startA, endA;
ifstream indata; // indata is like cin
int id; // variable for input value
indata.open(filename); // opens the file
if(!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
count1=0;
while ( !indata.eof() ) { // keep reading until end-of-file
indata >> id;
cout << "The id is " << id << endl;
if(id==1)
{
indata >> startPX >> startPY >> endPX >> endPY;
glBegin(GL_LINES);
glVertex2f(startPX, startPY); // origin of the line
glVertex2f(endPX, endPY); // ending point of the line
glEnd();
if(count1==0)
{
startPoints = (POINT3D *)malloc(sizeof(POINT3D));
endPoints = (POINT3D *)malloc(sizeof(POINT3D));
}
else
{
startPoints = (POINT3D *)realloc(startPoints,sizeof(POINT3D)*(count1+1));
endPoints = (POINT3D *)realloc(endPoints,sizeof(POINT3D) * (count1+1));
}
startPoints[count1].x = startPX;
startPoints[count1].y = startPY;
startPoints[count1].z = 0.0f;
endPoints[count1].x = endPX;
endPoints[count1].y = endPY;
endPoints[count1].z = 0.0f;
count1++;
}
}
indata.close();
cout << "End-of-file reached.." << endl;
}
void CRevolutionProjView::drawSurface()
{
double PI = 4.0 * atan(1.0);
//I have x and y points;
//count1 = numberof points
//theta = 0 to 360 degs.
//nsweep = number of sweeps. 360/nsweep = each angle;
int nsweep=4;
//no of profiles = nsweep + 1...
//each profile will have count1 no of lines...so count1 startpoints and count1 endPoints...
//so...total startPoints and endPoints for (nsweep+1) profiles = (nsweep+1) * count1...
POINT3D *totalStartPoints, *totalEndPoints;
totalStartPoints = new POINT3D[(nsweep+1)*count1];
totalEndPoints = new POINT3D[(nsweep+1)*count1];
int cnt1=0;
double theta, inter;
inter = (360/nsweep) * (PI/180);
theta = 0;
for(int i=0; i<(nsweep+1); i++)
{
for(int j=0; j
|
|
|
|
|
0. your formulae for y and z look ok
1. Do not use malloc (or any other alloc function) to allocate memory for POINT3D or any other class (or struct, which is essentially the same) type! Any class or struct may have constructors and destructors, neither of which will be called when using standard C allocation routines! Even though you didn't explicitely define either, the compiler does create some for you. And besides, you may want to add constructors or destructors later.
2. Don't use realloc, especially in the way you did (you're forcing a realloc on every single iteration of the loop!). Use standard container classes instead, such as std::vector (call #include <vector> ). They take care of reallocation and are orders of magnitude more efficient at it.
3. What happens with the rest of lines that do not start with '1'? Looks like the loop will just try their best on the rest of the line rather than skip to the next line. As there is no check on the number of inputs per line this will mess up the remainder of the input, as will any other unexpected mistake in the input file. Unfortunately the stream operators >> are not that helpful in this regard, check the member functions instead.
4. Your code is truncated.
6. Don't use global variables; the point arrays should be members of your revolution surface class. What would you do if you had two objects of type Revolution Surface?
7. A minor issue: make sensible objects and name them appropriately; a class that represents a 3D revolution surface is sensible, but what is the name 'RevolutionProjView' meant to indicate? What it does indicate is that this object is a view, which it is clearly not. Nor is it a projection. Why not just 'CRevolutionSurface' ?
Also the function name 'drawProfile' seems entirely inappropriate as it doesn't draw anything. Did you mean 'readProfile'?
|
|
|
|
|