IvankoB | 23 Jul 2012 13:41
Picon

TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Me need to have an application result code.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
IvankoB | 23 Jul 2012 13:52
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?


Also "TThreadComp.terminate" in its OnStarted so that to exit its  
OnExecute & OnTerminated on check "if terminated then exit;"
(this approach assumes errors revealed in OnStarted which should stop  
further thread running)

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Martin Schreiber | 23 Jul 2012 14:11
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 13:52:00 IvankoB wrote:
> Also "TThreadComp.terminate" in its OnStarted so that to exit its
> OnExecute & OnTerminated on check "if terminated then exit;"
> (this approach assumes errors revealed in OnStarted which should stop
> further thread running)
>
It should be.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Ivanko B | 23 Jul 2012 14:33
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Probably. There will be an immediate abort of the program without calling
 finalize routines.
====================
Which checks to perform from the thread for already not existing
widgets of main application so that to eliminate AV etc ?

2012/7/23, Martin Schreiber <mse00000@...>:
> On Monday 23 July 2012 13:52:00 IvankoB wrote:
>> Also "TThreadComp.terminate" in its OnStarted so that to exit its
>> OnExecute & OnTerminated on check "if terminated then exit;"
>> (this approach assumes errors revealed in OnStarted which should stop
>> further thread running)
>>
> It should be.
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> mseide-msegui-talk mailing list
> mseide-msegui-talk@...
> https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
(Continue reading)

Martin Schreiber | 23 Jul 2012 15:02
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 14:33:54 Ivanko B wrote:
> Probably. There will be an immediate abort of the program without calling
>  finalize routines.
> ====================
> Which checks to perform from the thread for already not existing
> widgets of main application so that to eliminate AV etc ?
>
Probably. Although you should ask FPC if it is safe.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
IvankoB | 23 Jul 2012 14:02
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Which are the exact conditions of calling OnStarted, OnExecute &  
OnTerminated ? Where form can me terminate, pause & kill the thread ?

PS: Since me still can't get proper threading mechanics, Me have dead lock  
in my application.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Martin Schreiber | 23 Jul 2012 15:06
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 14:02:02 IvankoB wrote:
> Which are the exact conditions of calling OnStarted, OnExecute &
> OnTerminated ? Where form can me terminate, pause & kill the thread ?
>

"
function tthreadcomp.threadproc(sender: tmsethread): integer;
begin
 fthread:= teventthread(sender);
 try
  if assigned(fonstart) then begin
   application.lock;
   try
    fonstart(self);
   finally
    application.unlock;
   end;
  end;
  if assigned(fonexecute) then begin
   fonexecute(self);
  end;
  if assigned(fonterminate) then begin
   application.lock;
   try
    fonterminate(self);
   finally
    application.unlock;
   end;
  end;
  result:= 0;
(Continue reading)

Martin Schreiber | 23 Jul 2012 20:11
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 15:06:16 Martin Schreiber wrote:
> On Monday 23 July 2012 14:02:02 IvankoB wrote:
>
> > PS: Since me still can't get proper threading mechanics, Me have dead
> > lock in my application.
>
> This is normal while working with threaded applications. ;-)
>
Or
Welcome in multi thread world! :-)

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Sieghard | 23 Jul 2012 20:57
Picon
Favicon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Hallo IvankoB,

Du schriebst am Mon, 23 Jul 2012 17:02:02 +0500:

> PS: Since me still can't get proper threading mechanics, Me have dead
> lock in my application.

Did you make sure that all ressources are reserved strictly in the sme
order everywhere they're used? Requesting ressources in varying order is a
sure method to create deadlocks:

   A: request Ra, request Rb
   B: request Rb, request Ra

If the order of processing is A:Ra, B:Rb, then you have it.
Try it with B reqesting the other way, and see if you can create a deadlock
that way. Then you can proceed to more complex scenarios.  ;-)

--

-- 
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
(Continue reading)

Ivanko B | 23 Jul 2012 22:37
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Set the global
 variable "ExitCode" and  set application.terminated to true.
=================
This looks as a solution.

2012/7/23, Sieghard <s_c_h_s@...>:
> Hallo IvankoB,
>
> Du schriebst am Mon, 23 Jul 2012 17:02:02 +0500:
>
>> PS: Since me still can't get proper threading mechanics, Me have dead
>> lock in my application.
>
> Did you make sure that all ressources are reserved strictly in the sme
> order everywhere they're used? Requesting ressources in varying order is a
> sure method to create deadlocks:
>
>    A: request Ra, request Rb
>    B: request Rb, request Ra
>
> If the order of processing is A:Ra, B:Rb, then you have it.
> Try it with B reqesting the other way, and see if you can create a deadlock
> that way. Then you can proceed to more complex scenarios.  ;-)
>
> --
> (Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
> nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
> -----------------------------------------------------------
> Mit freundlichen Grüßen, S. Schicktanz
> -----------------------------------------------------------
(Continue reading)

Ivanko B | 23 Jul 2012 22:57
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Which are conditions of terminating (finishing) thread ?

2012/7/24, Ivanko B <ivankob4mse2@...>:
> Set the global
>  variable "ExitCode" and  set application.terminated to true.
> =================
> This looks as a solution.
>
> 2012/7/23, Sieghard <s_c_h_s@...>:
>> Hallo IvankoB,
>>
>> Du schriebst am Mon, 23 Jul 2012 17:02:02 +0500:
>>
>>> PS: Since me still can't get proper threading mechanics, Me have dead
>>> lock in my application.
>>
>> Did you make sure that all ressources are reserved strictly in the sme
>> order everywhere they're used? Requesting ressources in varying order is
>> a
>> sure method to create deadlocks:
>>
>>    A: request Ra, request Rb
>>    B: request Rb, request Ra
>>
>> If the order of processing is A:Ra, B:Rb, then you have it.
>> Try it with B reqesting the other way, and see if you can create a
>> deadlock
>> that way. Then you can proceed to more complex scenarios.  ;-)
>>
>> --
(Continue reading)

Martin Schreiber | 24 Jul 2012 05:33
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 22:57:43 Ivanko B wrote:
> Which are conditions of terminating (finishing) thread ?
>
Exiting onexecute.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
IvankoB | 24 Jul 2012 10:05
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Strangely but the below code doesn't redraw the label if called from  
OnTerminate
(checked for sure that the program flow enters this code)
//-------------------------------------------

begin
//application.lock;
try
   {выйти из программы по завершении sender.OnExecute}
   case RESULTCODETY(ExitCode) of
     SUCCESS: begin
       lblFinStatus.caption:= 'Завершено успешно.';
       lblFinStatus.color:= cl_ltgreen;
     end;
     CANCELLED: begin
       lblFinStatus.caption:= 'Отменено.';
       lblFinStatus.color:= cl_ltblue;
     end
     else {FAILED}
       lblFinStatus.caption:= 'Произошла ощибка.';
       lblFinStatus.color:= cl_ltred;
   end;
finally
//  application.unlock;
end;
waitus(1000000);

//-------------------------------------------

but does it successfully if called at end of OnExecute.
(Continue reading)

Martin Schreiber | 24 Jul 2012 10:23
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Tuesday 24 July 2012 10:05:16 IvankoB wrote:
> Strangely but the below code doesn't redraw the label if called from
> OnTerminate
> (checked for sure that the program flow enters this code)
> //-------------------------------------------
>
> begin
> //application.lock;
> try
>    {выйти из программы по завершении sender.OnExecute}
>    case RESULTCODETY(ExitCode) of
>      SUCCESS: begin
>        lblFinStatus.caption:= 'Завершено успешно.';
>        lblFinStatus.color:= cl_ltgreen;
>      end;
>      CANCELLED: begin
>        lblFinStatus.caption:= 'Отменено.';
>        lblFinStatus.color:= cl_ltblue;
>      end
>      else {FAILED}
>        lblFinStatus.caption:= 'Произошла ощибка.';
>        lblFinStatus.color:= cl_ltred;
>    end;
> finally
> //  application.unlock;
> end;

Application is locked here (onterminate is called in locked state).

> waitus(1000000);
(Continue reading)

Martin Schreiber | 23 Jul 2012 14:08
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 13:41:35 IvankoB wrote:
> Me need to have an application result code.
>
Probably. There will be an immediate abort of the program without calling 
finalize routines.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
IvankoB | 23 Jul 2012 17:47
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Probably. There will be an immediate abort of the program without calling
> finalize routines.
>

Unit's "finalization" is called. But GDB still shows the apllication  
running after "halt", is it correct ?

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Martin Schreiber | 23 Jul 2012 17:57
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 17:47:33 IvankoB wrote:
> Probably. There will be an immediate abort of the program without calling
>
> > finalize routines.
>
> Unit's "finalization" is called. But GDB still shows the apllication
> running after "halt", is it correct ?
>
I don't know.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Ivanko B | 23 Jul 2012 19:52
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Me mean the HALT(n) call from within a thread but GDB still looks like
the main app is still running & some more inadequate "things" after
that.
How do You debug threaded apps ?

2012/7/23, Martin Schreiber <mse00000@...>:
> On Monday 23 July 2012 17:47:33 IvankoB wrote:
>> Probably. There will be an immediate abort of the program without calling
>>
>> > finalize routines.
>>
>> Unit's "finalization" is called. But GDB still shows the apllication
>> running after "halt", is it correct ?
>>
> I don't know.
>
> Martin
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> mseide-msegui-talk mailing list
> mseide-msegui-talk@...
> https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
>

(Continue reading)

Martin Schreiber | 23 Jul 2012 20:11
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 19:52:50 Ivanko B wrote:
> Me mean the HALT(n) call from within a thread but GDB still looks like
> the main app is still running & some more inadequate "things" after
> that.

Can you step into the halt() call?

> How do You debug threaded apps ?
>
Open the thread window, select the thread you want to debug. Linux gdb works 
better for debugging threads then the Windows version. 
Sometimes 'Project'-'Options'-'Call GUI_DEBUGBEGIN/GUI_DEBUGEND must be 
activated in order to prevent gdb crashes.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Ivanko B | 23 Jul 2012 20:26
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

Can you step into the halt() call?
=========
Hmm...me don't have actual FPC sources at that machine.

Welcome in multi thread world! :-)
=========
Too much new - up to overloading my brain :) Threading, SSL|Crypto,
networking, HTTP, archiving,..

2012/7/23, Martin Schreiber <mse00000@...>:
> On Monday 23 July 2012 19:52:50 Ivanko B wrote:
>> Me mean the HALT(n) call from within a thread but GDB still looks like
>> the main app is still running & some more inadequate "things" after
>> that.
>
> Can you step into the halt() call?
>
>> How do You debug threaded apps ?
>>
> Open the thread window, select the thread you want to debug. Linux gdb works
>
> better for debugging threads then the Windows version.
> Sometimes 'Project'-'Options'-'Call GUI_DEBUGBEGIN/GUI_DEBUGEND must be
> activated in order to prevent gdb crashes.
>
> Martin
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
(Continue reading)

Martin Schreiber | 23 Jul 2012 20:52
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

On Monday 23 July 2012 20:26:00 Ivanko B wrote:
> Can you step into the halt() call?
> =========
> Hmm...me don't have actual FPC sources at that machine.
>
I would not call halt() in a running application. Set the global 
variable "ExitCode" and  set application.terminated to true.

Martin

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
IvankoB | 24 Jul 2012 11:38
Picon

Re: TThreadComp: is it safe to call HALT(rc) in its OnTerminate ?

>> How do You debug threaded apps ?
>>
> Open the thread window, select the thread you want to debug. Linux gdb  
> works
> better for debugging threads then the Windows version.
> Sometimes 'Project'-'Options'-'Call GUI_DEBUGBEGIN/GUI_DEBUGEND must be
> activated in order to prevent gdb crashes.
>

For evil apps it also good to restart GDB after app run :)
( todays' experience )

PS: ExitCode+Terminate work excellent.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane