Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Former Member Absent Member.
Absent Member.
403 views

[archive] Threads

[Migrated content. Thread originally posted on 17 February 2005]

I'm just wondering if my code is a good way to handle threads.
The routines are working great, but I know one has to be carefull with threads.

PROGRAM-1 fills a grid with data after it has been sorted.
The user can click another heading of the grid wich calls the sort-routine again on other data.

It's my intention to give the user a message when the sort is taking too long (> 3 Secs).

If it's a good way of programming threads, maybe some other users can use the source as well.

Kind regards 😉

PROGRAM-1 does the sort and fills the grid.

       FILL-GRID.
          PERFORM FILL00 THRU FILL99.
       FILL00.
          PERFORM THREAD "TIMING" HANDLE IN TIMING-HANDLE.

       * DO THE SORT AND FILL THE GRID

       * END OF SORT AND FILLING GRID.

       FILL88.
          SET END-THREAD TO TRUE.
          STOP THREAD TIMER-HANDLE.
          STOP THREAD MESSAGE-HANDLE.
       FILL99.

       TIMING.
           PERFORM TIMER00 THRU TIMER99.
       TIMER00.
           INITIALIZE DIFF-SEC SA-SEC1 SA-SEC2 THREAD-STATUS.
           ACCEPT WTIME FROM TIME.
           MOVE SEC OF WTIMER TO SA-SEC1.

           PERFORM UNTIL DIFF-SEC = 3
              ACCEPT WTIME FROM TIME
              MOVE SEC OF WTIMER  TO SA-SEC2
              SUBTRACT SA-SEC1 FROM SA-SEC2 GIVING DIFF-SEC
           END-PERFORM.

           IF DIFF-SEC = 3
           AND NOT END-THREAD
              MOVE 1            TO READ-MESS-NR(1)
              MOVE 2            TO READ-MESS-NR(2)
              CALL THREAD "MESSAGE" HANDLE MESSAGE-HANDLE
                   USING LNK.
       TIMER99.
 


MESSAGE is a separate program were messages are been displayed to the user if the grid hasn't been filled with data after 3 secs.

Maybe it would be better to make it a routine, instead of a seperate program ?

       Form1-Aft-Initdata.
           PERFORM BEGIN00 THRU BEGIN99.
       BEGIN00.
           RECEIVE THREAD-STATUS FROM ANY THREAD.
           IF END-THREAD
              SET EXIT-PUSHED TO TRUE
           ELSE
              GO TO BEGIN00
           END-IF.
       BEGIN99.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.