andyhill Posted October 16, 2017 Share Posted October 16, 2017 I have the following code that is supposed to update a progressbar while emailing (pbWaiting updating works):- ... if Assigned(job) then begin if not (job.Finished or job.Terminated) then begin job.Terminate; end; job.Free; end; // job:= TJobThread.Create; job.FreeOnTerminate:= False; pbWaiting.Position:= 4; job.Execute; ON EXECUTION WE NEVER PROGRESS TO THE NEXT LINE (SendMail) ? // UniMainModule.SendMail(LoginForm.edtEmail.Text, LoginForm.edtPassword.Text, edtFirstName.Text, edtLastName.Text, edtPhone.Text); // job.JobCounter:= 100; job.Terminate; Please advise - thanks in advance Quote Link to comment Share on other sites More sharing options...
andyhill Posted October 17, 2017 Author Share Posted October 17, 2017 procedure TJobThread.Execute; begin JobCounter:= 6; while not Terminated and (JobCounter < 100) do begin Inc(JobCounter); if JobCounter > 99 then begin JobCounter:= 6; end; UniSession.AddJS(Format('NewAccountRequestForm.pbWaiting.updateProgress(%d/%d, ''Running...'', true);', [JobCounter, 100])); UniSession.Synchronize; Sleep(500); end; end; Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted October 17, 2017 Share Posted October 17, 2017 I think you should do it the other way around: send the e-mail in a thread. Quote Link to comment Share on other sites More sharing options...
andyhill Posted October 17, 2017 Author Share Posted October 17, 2017 The problem is that IdSMTP has long pauses even when using BeginWork, Work, Status, EndWork etc. and I wanted a fluid progress bar not one that jumps seconds apart. I would appreciate a code example of how to achieve this. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 17, 2017 Administrators Share Posted October 17, 2017 Hi, Why don't you use synchronize method in uniGUI. Please see SyncClientUpdate -1 to 6 demos. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 17, 2017 Administrators Share Posted October 17, 2017 procedure TJobThread.Execute; begin JobCounter:= 6; while not Terminated and (JobCounter Inc(JobCounter); if JobCounter > 99 then begin JobCounter:= 6; end; UniSession.AddJS(Format('NewAccountRequestForm.pbWaiting.updateProgress(%d/%d, ''Running...'', true);', [JobCounter, 100])); UniSession.Synchronize; Sleep(500); end; end; A big NO! You can't use uniGUI methods inside a thread. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted October 17, 2017 Administrators Share Posted October 17, 2017 You don't need to use a thread. Perform the task inside a uniGUI event using Synchronize event. Quote Link to comment Share on other sites More sharing options...
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.