THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/05/2005 at 09:15, xxxxxxxx wrote:
Ok i pinned it down to a call to GeDialog::SetTitle() in between GeSpinLock() and GeSpinUnlock()
maybe it's API bug.. if you change things in AsyncTest.cpp from the SDK Examples like this, then it will also freeze. And i see nothing that would be illegal.
//added
class TestThread : public Thread
{
public:
virtual void Main()
{
someData = 0;
while( !TestBreak() )
{
GeSleep( 400 );
LockData();
for( LONG i=0; i<1000; ++i )
{
++someData;
}
UnlockData();
}
}
void LockData() { GeSpinLock( &lock; ); };
void UnlockData() { GeSpinUnlock( &lock; ); };
ULONG* GetData() { return &someData; };
GeUserArea *ua;
GE_SPINLOCK lock;
private:
ULONG someData;
};
class SDKGradientArea : public GeUserArea
{
public:
SDKGradientGadget ggtmp;
SDKGradient grad[MAXGRADIENT];
LONG count,interpolation,type;
// added
TestThread thread;
SDKGradientArea(void);
virtual Bool Init(void);
virtual Bool GetMinSize(LONG &w;,LONG &h;);
virtual void Sized(LONG w,LONG h);
virtual void Draw(LONG x1,LONG y1,LONG x2,LONG y2);
virtual Bool InputEvent(const BaseContainer &msg;);
};
Bool SDKGradientArea::Init(void)
{
ggtmp.Init(this,grad,&count;,&interpolation;,MAXGRADIENT);
// added
thread.ua = this;
thread.lock = 0;
thread.Start( TRUE, FALSE );
return TRUE;
}
void SDKGradientArea::Draw(LONG x1,LONG y1,LONG x2,LONG y2)
{
if (!ggtmp.col) return;
LONG w = ggtmp.col->GetBw();
LONG h = ggtmp.col->GetBh();
// added
thread.LockData();
ULONG *data = thread.GetData();
GeDebugOut("data = %i",*data);
// this seems to cause a freeze
dlg->SetTitle( LongToString( *data ) );
thread.UnlockData();
DrawBitmap(ggtmp.col,0,0,w,h,0,0,w,h,0);
}