|
Yeah, I'm going to chock it up to what my teachers told me in high school - "You (as in I) need to slow down."
damn teachers!
|
|
|
|
|
Hello,
I have written one executable in C++ which runs from startup of 'All Users' in user's account. In order to give read and write permissions to the place where this executable reads and writes into a file and creates logs we have a service which gives the particular folder the ACL permissions. Using this concept even restricted user never faces any problem while trying to do any of its designed functionality till XP. But, in some cases starting from VISTA we get the executable visible in task manager but it does not do any thing and also not even makes the log.
I need to find why this happens. If any one knows please throw some light on this
Regards,
Kushagra
|
|
|
|
|
Kushagra Tiwari wrote: I need to find why this happens. If any one knows please throw some light on this
Have you tried running your application under the debugger to see what is happening?
|
|
|
|
|
|
Hi fellow CP-ers.
I worked with monstrous legacy C/C++ code where the GUI and business logic components are executed in the same thread. It worked fine, but the GUI is similar to Win 3.1 style: ugly clunky and yucky (sorry for hardcore 3.1-ers!).
Since then we upgraded our system with new GUI tools and processors. We decided to take this opportunity to untangle the system. We put all the biz logic in one thread (this hosts multiple apps, drawing or non-drawing), and all related GUI items (rendering loop, animations, and all its support classes) on the other thread. IMO, this is very beneficial since for example the button may animate fade in or out, etc, while the biz logic thread can still host other non-drawing applications. Note that we will try to do as much as we can locally in rendering thread if it doesn't involve biz logic (ex: highlights, international strings, etc). If it requires data, it will post to biz logic thread and retrieve it.
So this new guy came in and decided to put all the GUI classes back to the business logic thread. Rendering is still done on other thread, but now for every single little graphics primitives (think set colors, move obj to x,y, set transparency, etc) we need to send out a message. His reasoning is that it's too clumsy to post handler messages to other thread, he prefers call back, and he said it's common for most GUI frameworks to have this synchronous behavior.
Can someone help me explain why the synchronicity of button handler is so important? Am I missing something?
Don't we already have similar model of biz logic / presentation separation in present day web technology? (i.e. Fancy flash animations in your web browser sending/fetching data from the server, or AJAX heavily used by Google apps?)
|
|
|
|
|
The are two principles mixed together here:
1) Splitting business logic and GUI logic - This is good as it allows one to write unit-tests that can test the business-logic without needing to test using the GUI.
2) Using worker-threads to perform long running operations - This gives a good GUI experience, as the GUI remains responsive even when doing heavy processing.
Multi-threaded programming increases the complexity of the code. So it should only be introduced where it actually provides a performance boost.
I have no problem in understanding why your new developer wants to make synchronous requests as it is so much simpler.
I have no clue about your customer base, or the type of application you are building. But the tendency is that we work towards client/server based applications, where the client is launched through a web-browser (ASP.NET / Silverlight) and the Server is available from the Internet (Easy deployment, Centralized hosting and backup). In this scenario then the splitting of GUI and business logic should come natural.
modified on Monday, December 14, 2009 5:09 PM
|
|
|
|
|
I have a DLL that communications to COM ports (we will call dll 'A')
I would prefer to only have one instance of this dll in memory at all times
I have two projects a C# windows form project ('B') and a c++ dll ('C')
that both access the COM port dll('A')
I am going to merge the c++ dll('C') and the C# project('B') into one application('BC')
Seeing that they both access functions of the dll('A'), but are there own entity is it possible to make both projects access the same dll('A') in memory instead of loading it in twice?
the communication dll('A') has multiple threads and is quite complex, I do NOT want two instances, but need the functionality of dll('B') in project ('C')
hopefully as convoluted as that is, it makes sense
Thank you for your help
|
|
|
|
|
That is the whole idea behind DLLs, one instance in memory servicing multiple apps at one time.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
this code: define Bspline curve, when i run it, i found:
"program too big to fit in memory" (although i restart computer)
???
#include "StdAfx.h"
#include "process.h"
#ifndef _MYBSPLINE_H__
#define _MYBSPLINE_H__
#ifndef ABS
# define ABS(x) ((x<0) ? (-1*(x)) : x)
#endif
typedef struct _MYPOINT
{
double x;
double y;
} MYPOINT;
//----------------------------------------------------------------------------------------------------
class CMyBSpline
{
public:
CMyBSpline(void);
~CMyBSpline(void);
void SetDegree(int nK); // Thiet lap bac cua da thuc neu ban muon
void Generate(MYPOINT* pControl, int n); // Thuc hien sinh cac diem dua tren cac diem dieu khien
int GetPointNum(); // Tra ve so diem sinh ra
MYPOINT* GetPoints(); // Tra ve con tro tro toi dau mang chua cac diem sinh
private:
MYPOINT* m_pPoints; // Mang chua cac diem B-Spline
int m_nNum; // So diem tren B-Spline sinh ra
int m_nK; // Bac cua da thuc
int* m_pU; // Mang chua cac Knots
void AllocateBSplinePoints(int n); // Cap phat vung nho luu tru diem tren B-Spline
void FreeBSplinePoints(); // Giai phong vung nho luu tru diem tren B-Spline
void AllocateKnot(int n); // Cap phat vung nho chua diem Knot
void FreeKnot(); // Giap phong bo nho da cap phat de luu diem Knot
void ComputeKnots(int n); // Tinh toan Knots
double FactorN(int t, int k, double v); // Tinh he so da thuc Ni,k(u)
void ComputeP(MYPOINT* pControl, int n, double u, MYPOINT& pt); // Tinh gia tri da thuc P(u)
};
#endif
CMyBSpline::CMyBSpline(void)
{
m_nK = 4; // Mac dinh
m_pPoints = NULL;
m_nNum = 0;
m_pU = NULL;
}
CMyBSpline::~CMyBSpline(void)
{
FreeKnot();
FreeBSplinePoints();
}
// Cap phat vung nho luu tru diem tren B-Spline
// n: So diem can cap phat
void CMyBSpline::AllocateBSplinePoints(int n)
{
if (m_pPoints!=NULL)
FreeBSplinePoints();
m_pPoints = new MYPOINT[n];
m_nNum = n;
}
// Giai phong vung nho luu tru diem tren B-Spline
void CMyBSpline::FreeBSplinePoints()
{
if (m_pPoints!=NULL)
delete [] m_pPoints;
m_pPoints = NULL;
m_nNum = 0;
}
// Cap phat bo nho de luu diem Knot
// n: So diem control point
// So diem Knots la: n+m_nK+1
void CMyBSpline::AllocateKnot(int n)
{
if (m_pU!=NULL)
FreeKnot();
m_pU = new int[n+m_nK+1];
}
// Giai phong bo nho da cap phat de luu cac diem Knot
void CMyBSpline::FreeKnot()
{
if (m_pU!=NULL)
{
delete [] m_pU;
m_pU = NULL;
}
}
// n: So diem control point
// Mang Knots luu trong m_pU
void CMyBSpline::ComputeKnots(int n)
{
int j;
for (j=0; j<=n+m_nK; j++)
{
if (j<m_nK)
m_pU[j]=0;
else if ((m_nK<=j) && (j<=n))
m_pU[j]=j-m_nK+1;
else if (j>n)
m_pU[j]=n-m_nK+2;
}
}
// Tinh toan de quy he so da thuc: Ni,k(u)
// i: 0<=i<=n
// k: Bac cua da thuc
// u: La diem can tinh
double CMyBSpline::FactorN(int i, int k, double u)
{
double value;
if (k==1) // Dieu kien dung de quy
{
if ((m_pU[i]<=u) && (u<m_pU[i+1]))
value=1;
else
value=0;
}
else
{
if ((m_pU[i+k-1]==m_pU[i]) && (m_pU[i+k]==m_pU[i+1])) // Kiem tra dieu kien chia cho 0
value = 0;
else if (m_pU[i+k-1]==m_pU[i]) // Neu mau so bang 0 thi tinh theo cach khac
value = (m_pU[i+k] - u) / (m_pU[i+k] - m_pU[i+1]) * FactorN(i+1, k-1, u);
else if (m_pU[i+k]==m_pU[i+1]) // Neu mau so bang 0 thi tinh theo cach khac
value = (u - m_pU[i]) / (m_pU[i+k-1] - m_pU[i]) * FactorN(i, k-1, u);
else
value = (u - m_pU[i]) / (m_pU[i+k-1] - m_pU[i]) * FactorN(i, k-1, u) +
(m_pU[i+k] - u) / (m_pU[i+k] - m_pU[i+1]) * FactorN(i+1, k-1, u);
}
return value;
}
// Tinh gia tri da thuc P(u)
// pControl: Mang chua diem control point
// n: So diem control poiint
// u: Diem tinh
void CMyBSpline::ComputeP(MYPOINT* pControl, int n, double u, MYPOINT& pt)
{
double dFactor;
// Khoi tao lai cac gia tri
pt.x = 0;
pt.y = 0;
for (int i=0; i<=n; i++)
{
dFactor = FactorN(i, m_nK, u); // same blend is used for each dimension coordinate
pt.x += (pControl[i]).x * dFactor;
pt.y += (pControl[i]).y * dFactor;
}
}
// Thiet lap bac cua da thuc neu ban muon
void CMyBSpline::SetDegree(int nK)
{
m_nK = nK;
}
// Sinh ra cac diem tren B-Spline
// pControl: Mang chua cac diem dieu khien
// n: So diem dieu khien
void CMyBSpline::Generate(MYPOINT* pControl, int n)
{
// Hieu chinh lai gia tri cho phu hop
n--;
// Xoa cac diem cu
FreeBSplinePoints();
// Kiem tra dieu kien
if (n+2<=m_nK)
return; // Khong co duong cong
// Tinh so diem
// Tinh tuong doi so diem sinh B-Spline
int nNum = 0;
int nDiv = 0;
for (int i=0; i<n; i++)
{
nDiv = (int)(max(ABS(pControl[i+1].x-pControl[i].x), ABS(pControl[i+1].y-pControl[i].y))/0.5);
if (nDiv==0)
nDiv = 1;
nNum += nDiv+1;
}
// Cap phat va tinh cac diem Knots
AllocateKnot(n);
ComputeKnots(n);
// Cap phat bo nho luu diem tren B-Spline
AllocateBSplinePoints(nNum);
// Sinh cac diem tren B-Spline
MYPOINT pt;
double dInc = (double)(n-m_nK+2)/nNum;
double u = 0;
for (int nIdx=0; nIdx< nNum; nIdx++)
{
ComputeP(pControl, n, u, pt);
m_pPoints[nIdx].x = pt.x;
m_pPoints[nIdx].y = pt.y;
u += dInc;
}
FreeKnot();
}
int CMyBSpline::GetPointNum()
{
return m_nNum;
}
MYPOINT* CMyBSpline::GetPoints()
{
return m_pPoints;
}
|
|
|
|
|
|
Does this help?
"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
|
|
|
|
|
thank u
i run another code and it run normaly.
only this code has " program too big to fit in memory "
|
|
|
|
|
lan sau post nho' them tag <pre></pre> truoc va sau dong code nhe, kho' nhin qua'
|
|
|
|
|
^^
em moi tap code thoi, anh thong cam...
|
|
|
|
|
what are these error ?
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
|
|
|
|
|
Are you sure that you've #includ ed <process.h> ? Also, why are you wanting to use _endthreadex ? Just return from the thread function. That's the best way to end a thread.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
i find a code and try to run it.
many errors that i don't know why !
|
|
|
|
|
Well, that's a good reason to start learning.
This signature was proudly tested on animals.
|
|
|
|
|
They are linker errors. See here.
"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
|
|
|
|
|
Can anyone advise on this problem on Visual Studio 2005 MFC application?
When I add any new variables; e.g. say a structured array of some 256 elements my program crashes with an exception where the code was OK in all previous versions.
I am assuming that I have reached some limits on heap or stacks etc. and think that addresses/pointers are being overwritten.
Can some suggest and options to set to increase the programs resources.
Note the program reads in some large files and uses the CStringArray for lots o string processing.
Many thanks,
Graham.
grahamfff
|
|
|
|
|
What precisely was the exception? Any relevant code that you can show us?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I just tried to invoke the crash and the code section it occured in, but the problem has gone away. I did a work around when I encountered this crash and just wanted to try and sort it out now.
I just wondered if I used a #define items inside the structure I has defining.
Anyway should I worry about the data segment of the program as I am processing very large text files as already I needed to upgrade counters from short to int.
Regards,
Graham.
grahamfff
|
|
|
|
|
My guess is that by adding an extra entry then you changed the alignment of memory, and exposed an old bug where it accessed invalid memory.
Usually these bugs are hidden again by modifying the application again so the alignemtn of memory changes again.
|
|
|
|
|
Hello
When a TextBox is disabled the contents of that will all become greyish.
How to avoid that, and keep the contents in black even when
the TextBox is in disabled state?
Thanks in advance
|
|
|
|
|
You should really stick to the standards, otherwise your UI will be a hell to use. Maybe you don't want to disable the edit box but set it read-only[^] ?
|
|
|
|