dionel1969 Posted August 22, 2012 Posted August 22, 2012 Hello: I have a process that is responsible for "Sale Process" of various points of sale. This procedure takes time depending on the amount of POS that were working in a day and depending on the sale of each of these POS. Then, when the sale is small no problem, but when is large before processing finished application gives an error of "Time Out". The question is: How I can do to have a process feedback directly from the server in the window showing the results and avoid the time-out error? I put a timer, but does not start at the time indicated. procedure TProcessForm.ProcessSale; begin try fProcessStart := Now; tmrProcess.Enable := True; ProcessSaleInternal; finally tmrProcess.Enable := False; end end; procedure TProcessForm.tmrProcessTimer(Sender: TObject); begin pnlProcessing.Caption := 'Procesando Venta. Tiempo de Procesamiento: ' + IntToStr(MillisecondsBetween(Now, fProcessStart)); end; Quote
Ronak Posted August 23, 2012 Posted August 23, 2012 Hello, I put a timer, but does not start at the time indicated. Timer triggers repetitively, it starts when enabled, not for time indicated, if so let know.. Now about TimeOut.., See UniGui Demos SessionTimeout Try begin UniMainModule.AllowTerminate:=False; ProcessForm.ProcessSale(); UniMainModule.AllowTerminate:=True; showmsg; end; procedure TUniMainModule.UniGUIMainModuleSessionTimeout(ASession: TObject; var ExtendTimeOut: Integer); begin if not AllowTerminate then begin ExtendTimeOut:=15000; // extend session for another 15 seconds end; end; Quote
dionel1969 Posted August 23, 2012 Author Posted August 23, 2012 Thank you. I will try it today. Sorry for my delay in the answer, but I was so busy yesterday with other things. Thank you again. Quote
Administrators Farshad Mohajeri Posted August 23, 2012 Administrators Posted August 23, 2012 You must implement a thread and run the lengthy operation in that thread. Then inform the client using a UniTimer about the progress status. There was a example regarding this somewhere in samples forum. Quote
estrify Posted August 24, 2012 Posted August 24, 2012 You must implement a thread and run the lengthy operation in that thread. Then inform the client using a UniTimer about the progress status. There was a example regarding this somewhere in samples forum. Please look at http://forums.unigui.com/index.php?/topic/1479-progressbar-multithreading-demo/ It contains a simple example showing how to do this with UniGUI. Quote
dionel1969 Posted August 24, 2012 Author Posted August 24, 2012 Hello, I put a timer, but does not start at the time indicated. Timer triggers repetitively, it starts when enabled, not for time indicated, if so let know.. Of course, I do understand this, but I wanted to say that the Timer only become to Enable when the Form Show at init, not later. It est, I want to set Enable to True before Start Sale Process and then when the process come to finish set Enable to False. So, Timer will trigger Timer Events and I will use theses events for refreshing "Sale Process Status and Position". This is not working: procedure TUniMainModule.UniGUIMainModuleSessionTimeout(ASession: TObject; var ExtendTimeOut: Integer); begin if not AllowTerminate then begin ExtendTimeOut:=15000; // extend session for another 15 seconds end; end; The Event is not triggering by MainModule. Thank you again. Quote
Ronak Posted August 25, 2012 Posted August 25, 2012 I also observed the same, that timer doesn't triggers as long as the main thread is busy in processing some ProcessSaleInternal procedure. also, UniGUIMainModuleSessionTimeout doesn't execure as the main thread is busy. This lengthy operation have to be processed in a thread, as Farshad have already suggested. Regards Quote
dionel1969 Posted August 25, 2012 Author Posted August 25, 2012 I also observed the same, that timer doesn't triggers as long as the main thread is busy in processing some ProcessSaleInternal procedure. also, UniGUIMainModuleSessionTimeout doesn't execure as the main thread is busy. This lengthy operation have to be processed in a thread, as Farshad have already suggested. Regards Ok, Thanks a lot for your help. I'm now converting the Process, because it come "as is" from the same application but a versiion that is running in Windows. For a few POSes and a few tickets it works well, the problem come when there are a lot of tickets. So, it is obvious that I have to convert the process to run it in a separate thread and then I need to use timer to get feed back from server side. Thanks again. Dionel Quote
Administrators Farshad Mohajeri Posted August 25, 2012 Administrators Posted August 25, 2012 I also observed the same, that timer doesn't triggers as long as the main thread is busy in processing some ProcessSaleInternal procedure. also, UniGUIMainModuleSessionTimeout doesn't execure as the main thread is busy. This lengthy operation have to be processed in a thread, as Farshad have already suggested. Regards Like all other events Timer event executes cooperatively and only executes when owner session is not busy running other events. 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.