TEAM ENVI^ ENVIMODE=1| ENVI^ FORCELOCAL=1
WIN1
_SUB WIN1,W289H249,测试线程,
    ITEM ITEM2,L42T100W60H30,线程,exec %&MyName% LOAD %&CurFile%*OnTest,
    SET  &&STK=1024K 
    SET  &&STK=256K 
    ENVI-env hwnd0=%&__WinID%
    ITEM ITEM3,L165T98W60H30,小线程,exec %&MyName% LOAD  %&CurFile%*OnTest  **st:%&STK%,
    LABE LABE4,L36T30W192H30,,,
    ENVI @this.MSG=#1::&&wp,&&lp, ENVI @LABE4=%wp% 个线程   错误码:%wp% 
    SET &tp=WIN32
    IFEX $1=%&bX64%, SET tp=PECMD32 on Win64
    IFEX $3=%&bX64%, SET tp=PECMD64 on Win64
    IFEX $0=%&bX64%, SET tp=PECMD32 on Win32
    
    LABE LABE1,L37T1W160H22,%tp%,,
    ENVI @this.MSG=#2::&&wp,&&lp,  MESS* %wp% 线程 错误码 %wp%  @测试#OK  
_END


_SUB OnTest * 
    //IFEX X.LOG, LOGS * X.LOG
    TEAM ENVI^ ENVIMODE=1| ENVI^ FORCELOCAL=1
    WAIT 200
    ENVI-env  &&hwnd0=%hwnd0%
    SET &I=0
    SET &err=0
    SET &MyThread=THREAD %~1  WAIT 9990000
    LOOP #%&I%<5010,
    {
        ENVI @@SENDMSG=%hwnd0%:#1;%I%;%err%
         %MyThread%  
        SET err=%ERROR%
        IFEX $%err%>0, EXIT 
        CALC #I= %I% + 1
    }
    ENVI @@SENDMSG=%hwnd0%:#1;%I%;%err%
    ENVI @@SENDMSG=%hwnd0%:#2;%I%;%err%
_END
