Board index » cppbuilder » TThread::Synchronize in BDS2006

TThread::Synchronize in BDS2006


2005-12-13 10:29:39 PM
cppbuilder108
Using Synchronize method to call VCL main thread in C++ TP
BDS2006 doesn't work. Try the simple example below or Thread
example project in C++ Builder 6. Are there some problems in new
VCL version? Technical preview problem? Any Idea?
Mauro
void __fastcall TMyThread::PushTheButton(void)
{
Button1->Click();
}
void __fastcall TMyThread::Execute()
{
Synchronize((TThreadMethod)PushTheButton);
}
 
 

Re:TThread::Synchronize in BDS2006

Mauro Tronto wrote:
Quote
Using Synchronize method to call VCL main thread in C++ TP
BDS2006 doesn't work. Try the simple example below or Thread
example project in C++ Builder 6. Are there some problems in new
VCL version? Technical preview problem? Any Idea?
Is it not executing the "PushTheButton" method, or is it executing it on
an incorrect thread? BTW, I never knew TThread had this, I've always
handled this sort of thing with the Win32 API PostMessage(). Of course,
if Synchronize() still isn't working...
 

Re:TThread::Synchronize in BDS2006

Mauro Tronto wrote:
Quote
Using Synchronize method to call VCL main thread in C++ TP
BDS2006 doesn't work. Try the simple example below or Thread
What exactly doesn't work? Do you get syntax errors from the compiler? I
think you should.
.a
 

{smallsort}

Re:TThread::Synchronize in BDS2006

I just tried an experiment and it worked fine. Note that in your code,
your call to Synchronize is incorrect:
You wrote:
Quote
void __fastcall TMyThread::Execute()
{
Synchronize((TThreadMethod)PushTheButton);
}
Where it should be:
void __fastcall TMyThread::Execute()
{
Synchronize((TThreadMethod) &PushTheButton);
}
 

Re:TThread::Synchronize in BDS2006

Hello Sean,
Quote
Note that in your code,
your call to Synchronize is incorrect:
Synchronize((TThreadMethod) &PushTheButton);
As I remember, with funktion-pointers the &-Operator is not needed.
Harald
 

Re:TThread::Synchronize in BDS2006

"Harald Plontke" < XXXX@XXXXX.COM >wrote in message
Quote
As I remember, with funktion-pointers the &-Operator is not needed.
That is no longer the case with BDS 2006. When passing a method to
Synchronize(), you need to use the '&' now. That is an intentional change
in Borland's new C++ compiler.
Gmbit
 

Re:TThread::Synchronize in BDS2006

"Mauro Tronto" < XXXX@XXXXX.COM >wrote in message
Quote
Using Synchronize method to call VCL main thread in C++ TP
BDS2006 doesn't work.
Assuming you are getting a "cannot find match for..." error, then there is a
change in Borland's new C++ compiler for BDS 2006 that requires you to now
use the '&' operator when passing methods to Synchronize(), ie:
void __fastcall TMyThread::Execute()
{
Synchronize(&PushTheButton);
}
Gambit
 

Re:TThread::Synchronize in BDS2006

Hello Remy:
Using & operator to get function address it's a recomendation of new C++
standard???
Thanks.
Saludos
Sebastian
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >escribi?en el mensaje
Quote

...
That is no longer the case with BDS 2006. When passing a method to
Synchronize(), you need to use the '&' now. That is an intentional change
in Borland's new C++ compiler.


Gmbit


 

Re:TThread::Synchronize in BDS2006

Remy Lebeau (TeamB) wrote:
Quote

That is no longer the case with BDS 2006. When passing a method to
Synchronize(), you need to use the '&' now. That is an intentional change
in Borland's new C++ compiler.
Was this due to a change in the spec? Do you have insight as to why
this is now required?
 

Re:TThread::Synchronize in BDS2006

Yes Remy. That's the problem! I hope that borland changes the help file
(Synchronize entry) that doesn't expose this new requirement in the example
code (my example is cut & paste from help section). As you already know,
users using TThread objects in CB6 doesn't use '&' operator.
Thanks for your great help in the community.
Mauro
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >ha scritto nel messaggio
Quote

"Mauro Tronto" < XXXX@XXXXX.COM >wrote in message
news:439ee8e3$ XXXX@XXXXX.COM ...

>Using Synchronize method to call VCL main thread in C++ TP
>BDS2006 doesn't work.

Assuming you are getting a "cannot find match for..." error, then there is
a
change in Borland's new C++ compiler for BDS 2006 that requires you to now
use the '&' operator when passing methods to Synchronize(), ie:

void __fastcall TMyThread::Execute()
{
Synchronize(&PushTheButton);
}


Gambit


 

Re:TThread::Synchronize in BDS2006

"Sebastian Ledesma [Solidyne Labs]" <labo[no_sp@m]solidyne1.com>wrote in
message news:439f33a6$ XXXX@XXXXX.COM ...
Quote
Using & operator to get function address it's a
recomendation of new C++ standard???
Using '&' has always been part of the standard, but Borland never followed
it when it came to dealing with the VCL.
Gambit
 

Re:TThread::Synchronize in BDS2006

"Sean Hoffman" <seanhoffdontspammewhateveryoudo@hotmaildotcom>wrote in
message news:439f367b$ XXXX@XXXXX.COM ...
Quote
Was this due to a change in the spec?
No. It is to better conform with the existing spec.
Gambit
 

Re:TThread::Synchronize in BDS2006

Quote
Using '&' has always been part of the standard, but Borland never followed
it when it came to dealing with the VCL.
Maybe for C++, but back in the days when C ruled, before it was ruined
by this ++ {*word*99}, the name of a function resolved to its address. As it
shoudl be, IHMO.
 

Re:TThread::Synchronize in BDS2006

"Harald Plontke" < XXXX@XXXXX.COM >writes:
Quote
Hello Sean,

>Note that in your code,
>your call to Synchronize is incorrect:
>Synchronize((TThreadMethod) &PushTheButton);

As I remember, with funktion-pointers the &-Operator is not needed.
Actually, for non-member functions, the function type will implicitly
convert into a pointer to function (similarly to how arrays decay into
pointers to their first elements).
However, for standard C++ member pointers, you not only must use the
address-of operator, but you also MUST explicitly qualify the member
name with its class (example: &TFoo::func).
For closures, Borland took an unusused syntax and extended the
language that way. They work with members without the class
qualifiers, and they used to work without the & operator also, but it
seems that at least in some cases now, the address-of operator is
required for closures.
--
Chris (TeamB);
 

Re:TThread::Synchronize in BDS2006

"Sebastian Ledesma [Solidyne Labs]" <labo[no_sp@m]solidyne1.com>writes:
Quote
Hello Remy:

Using & operator to get function address it's a recomendation of new C++
standard???
Thanks.
__closures are not part of C++ at all, it's purely a Borland language
extension. The only changes discussed here are in the compiler's
implementation of Borland's language extension.
Note, a function-type (freestanding, non-member) and a
function-pointer are different things. However, a function-type can
convert into a function-pointer implicitly. Nothing has changed in
this regard in the language of C++.
--
Chris (TeamB);