dunham Posted January 25, 2016 Posted January 25, 2016 hi, i'm trying Synchronize to communicate between my thread and MainForm, i've got errors var iMsBetween : integer; ... procedure TThreadResults.DoJob ; var dTimeDebut : TDateTime; dTimeFin : TDateTime; i,j:integer; begin iMsBetween:=0; dTimeDebut:=Now; for i := 0 to High(integer) do begin j:=j+1; end; dTimeFin:=Now; iMsBetween := MilliSecondsBetween(dTimeDebut,Now); Synchronize(ThreadMess); end; procedure TThreadResults.ThreadMess(); begin MainForm.ShowElapsedTime(iMsBetween); end; procedure TMainForm.ShowElapsedTime(millisecs:integer); begin MessageDlg( 'elapsed time: ' + inttostr(millisecs), mtWarning, [mbOK], nil); end; i didn't found a classic thread example in the unigui samples for doing this , is there a way for doing this ? source code project: http://www.solidfiles.com/d/3e95135c9c/ Quote
rgreat Posted January 25, 2016 Posted January 25, 2016 UniGui app does not have main gui thread so Synchronize will not work. Initiative must come from client side. From timer event, for example. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.