Alaska Software Inc. - Re: Some thread questions.
Username: Password:
AuthorTopic: Re: Some thread questions.
Claudio Driussi Some thread questions.
on Fri, 13 Jul 2018 22:08:12 +0200
I'm working with threads, and I would like to know
how many threads are currently working, and if it's
possible I would like to kill the olders.

There are a way to do this?
I checked the documentation but there are no answers.

I'm using XPP 1.9 and soon 2.0

Best regards
Claudio
Osvaldo RamirezRe: Some thread questions.
on Fri, 13 Jul 2018 22:13:36 -0600
On 7/13/2018 2:08 PM, Claudio Driussi wrote:
 > I'm working with threads, and I would like to know
 > how many threads are currently working, and if it's
 > possible I would like to kill the olders.
 >
 > There are a way to do this?
 > I checked the documentation but there are no answers.
 >
 > I'm using XPP 1.9 and soon 2.0
 >
 > Best regards
 > Claudio
 >
Hope that Help, from the docs

 The example lists full and partial information
 about threads that can be retrieved with ThreadInfo()

    #include "Thread.ch"

    PROCEDURE Main
       LOCAL aInfo, aThread := { Thread():new(), Thread():new() }

       CLS
       aThread[1]:start( "Test1" )
       aThread[2]:start( "Test2" )

       ? "Retrieve all thread information"
       aInfo := ThreadInfo( THREADINFO_TID      + ;
                            THREADINFO_SYSTHND  + ;
                            THREADINFO_FUNCINFO + ;
                            THREADINFO_TOBJ       )

       AEval( aInfo, {|a| QOut( Var2Char(a) ) } )

       ?
       ? "Retrieve partial thread information"
       aInfo := ThreadInfo( THREADINFO_FUNCINFO + ;
                            THREADINFO_TID        )

       ?
       AEval( aInfo, {|a| QOut( Var2Char(a) ) } )
    RETURN


    PROCEDURE Test1
       DO WHILE .T.
          DispOutAt( 10, 10, Time() )
          Sleep(100)
       ENDDO
    RETURN


    PROCEDURE Test2
       LOCAL nCount := 0
       DO WHILE .T.
          DispOutAt( 12, 10, nCount ++ )
          Sleep(17)
       ENDDO
    RETURN

     Program output

     Retrieve all thread information
     {1, 324, 14, MAIN, thread}
     {2, 724, 31, TEST1, thread}
     {3, 748, 40, TEST2, thread}
    
     Retrieve partial thread information
     {1, 21, MAIN}
     {2, 31, TEST1}
     {3, 40, TEST2}

See also
Thread()
ThreadID()
ThreadObject()

File info
Include file
thread.ch
Static library
Xppui1.lib
Dynamic library
Xppui1.dll
Claudio Driussi Re: Some thread questions.
on Sat, 14 Jul 2018 11:14:44 +0200
Il 14/07/2018 06:13, Osvaldo Ramirez wrote:
> On 7/13/2018 2:08 PM, Claudio Driussi wrote:
>  > I'm working with threads, and I would like to know
>  > how many threads are currently working, and if it's
>  > possible I would like to kill the olders.
>  >
>  > There are a way to do this?
>  > I checked the documentation but there are no answers.
>  >
>  > I'm using XPP 1.9 and soon 2.0
>  >
>  > Best regards
>  > Claudio
>  >
> Hope that Help, from the docs
> 
>  The example lists full and partial information
>  about threads that can be retrieved with ThreadInfo()

Many thanks.


> 
>     #include "Thread.ch"
> 
>     PROCEDURE Main
>        LOCAL aInfo, aThread := { Thread():new(), Thread():new() }
> 
>        CLS
>        aThread[1]:start( "Test1" )
>        aThread[2]:start( "Test2" )
> 
>        ? "Retrieve all thread information"
>        aInfo := ThreadInfo( THREADINFO_TID      + ;
>                             THREADINFO_SYSTHND  + ;
>                             THREADINFO_FUNCINFO + ;
>                             THREADINFO_TOBJ       )
> 
>        AEval( aInfo, {|a| QOut( Var2Char(a) ) } )
> 
>        ?
>        ? "Retrieve partial thread information"
>        aInfo := ThreadInfo( THREADINFO_FUNCINFO + ;
>                             THREADINFO_TID        )
> 
>        ?
>        AEval( aInfo, {|a| QOut( Var2Char(a) ) } )
>     RETURN
> 
> 
>     PROCEDURE Test1
>        DO WHILE .T.
>           DispOutAt( 10, 10, Time() )
>           Sleep(100)
>        ENDDO
>     RETURN
> 
> 
>     PROCEDURE Test2
>        LOCAL nCount := 0
>        DO WHILE .T.
>           DispOutAt( 12, 10, nCount ++ )
>           Sleep(17)
>        ENDDO
>     RETURN
> 
>      Program output
> 
>      Retrieve all thread information
>      {1, 324, 14, MAIN, thread}
>      {2, 724, 31, TEST1, thread}
>      {3, 748, 40, TEST2, thread}
>     
>      Retrieve partial thread information
>      {1, 21, MAIN}
>      {2, 31, TEST1}
>      {3, 40, TEST2}
> 
> See also
> Thread()
> ThreadID()
> ThreadObject()
> 
> File info
> Include file
> thread.ch
> Static library
> Xppui1.lib
> Dynamic library
> Xppui1.dll