0

I use TIdHTTP component to load xml data from a bank in a seperate thread but my form is getting freezed during that time...

what could be the problem ?

I have a main form and thread class, in thread class i have a method called loadData and on thread::Execute i Synchronize(loadData);

when button gets clicked I created the instance of thread class like testThread *t=new testThread(false);

and that's all

when i click the button the main form freezes? even seperate thread didn't help????

Please help!!!

Suhrob Samiev
  • 1,528
  • 1
  • 25
  • 57

1 Answers1

0

Synchronize() is running your loadData() method in the context of the main thread, not in the context of your worker thread. That is why your main thread blocks while loadData() is busy. You are misusing Synchronize(), rendering your thread useless. You need to do the bulk of your thread work outside of Synchronize(), and then use Synchronize() only to perform small updates in the main thread when needed, like displaying status (even then, Synchronize() is not always the best choice for that).

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770