Skip to main content

The company I'm working at wants to apply multitasking for 3 programs.

i.e.

1. menu calls program A,

2. minimize program A, go back to menu and call program B

3. minimize program B, go back to menu and call program C

4. switch to any 3 opened programs at will

I found out from the guides that multithreading is the best solution for this. So, I tried this in the main menu, so that every called program has its own thread:

 

CALL THREAD PROG-WPATH HANDLE THREAD-1 USING PROG-ID, PROG-PARAMETER EXCEPTION STOP THREAD THREAD-1

 

 And in the called program, I tried this:

 

DISPLAY INDEPENDENT WINDOW LINES 21 SIZE 112 CELL SIZE = ENTRY-FIELD FONT SEPARATE TITLE-BAR MODELESS NO SCROLL NO WRAP AUTO-MINIMIZE, TITLE S-WINDOW-TITLE BIND TO THREAD, HANDLE S-WINDOW. DISPLAY TOOL-BAR, LINES 2.2 BACKGROUND-LOW HANDLE S-TOOLBAR. DISPLAY FRAME AT 0102 LINES 20.7 CELL SIZE 110 RAISED.

 

I also changed STOP RUN to STOP THREAD. 

As you can see in Capture.png, the thread is started but the debugger just exits after the CALL THREAD line and nothing happened. So I changed the thread via the debugger. The program opened but cannot read inputs and became stuck, so I had to close everything via the task manager.

 

Edit:

From https://www.microfocus.com/documentation/extend-acucobol/1000/BKUSUSPROGS066.html

To use this option you code your program in such a way that each modeless window runs in a separate thread, and you use the phrase LINK TO THREAD or BIND TO THREAD when you create each window. This phrase instructs the runtime to handle the CMD-ACTIVATE events on its own. In this arrangement, when a CMD-ACTIVATE event occurs, the runtime suspends the current thread and activates the new window.

This is exactly what I did above, but I couldn't get it to work. Any advice would be helpful.

The company I'm working at wants to apply multitasking for 3 programs.

i.e.

1. menu calls program A,

2. minimize program A, go back to menu and call program B

3. minimize program B, go back to menu and call program C

4. switch to any 3 opened programs at will

I found out from the guides that multithreading is the best solution for this. So, I tried this in the main menu, so that every called program has its own thread:

 

CALL THREAD PROG-WPATH HANDLE THREAD-1 USING PROG-ID, PROG-PARAMETER EXCEPTION STOP THREAD THREAD-1

 

 And in the called program, I tried this:

 

DISPLAY INDEPENDENT WINDOW LINES 21 SIZE 112 CELL SIZE = ENTRY-FIELD FONT SEPARATE TITLE-BAR MODELESS NO SCROLL NO WRAP AUTO-MINIMIZE, TITLE S-WINDOW-TITLE BIND TO THREAD, HANDLE S-WINDOW. DISPLAY TOOL-BAR, LINES 2.2 BACKGROUND-LOW HANDLE S-TOOLBAR. DISPLAY FRAME AT 0102 LINES 20.7 CELL SIZE 110 RAISED.

 

I also changed STOP RUN to STOP THREAD. 

As you can see in Capture.png, the thread is started but the debugger just exits after the CALL THREAD line and nothing happened. So I changed the thread via the debugger. The program opened but cannot read inputs and became stuck, so I had to close everything via the task manager.

 

Edit:

From https://www.microfocus.com/documentation/extend-acucobol/1000/BKUSUSPROGS066.html

To use this option you code your program in such a way that each modeless window runs in a separate thread, and you use the phrase LINK TO THREAD or BIND TO THREAD when you create each window. This phrase instructs the runtime to handle the CMD-ACTIVATE events on its own. In this arrangement, when a CMD-ACTIVATE event occurs, the runtime suspends the current thread and activates the new window.

This is exactly what I did above, but I couldn't get it to work. Any advice would be helpful.

I take it each of the programs launched via thread have an accept 

 ACCEPT MAINTENANCE-SCREEN 
         ALLOWING MESSAGES FROM LAST THREAD

 https://www.microfocus.com/documentation/extend-acucobol/103/extend-Interoperability-Suite/BKUSUSPROGS066.html

 


I take it each of the programs launched via thread have an accept 

 ACCEPT MAINTENANCE-SCREEN 
         ALLOWING MESSAGES FROM LAST THREAD

 https://www.microfocus.com/documentation/extend-acucobol/103/extend-Interoperability-Suite/BKUSUSPROGS066.html

 

Do you mean something like this? 

DISPLAY SELECT-SCR. ACCEPT SELECT-SCR. ... DISPLAY PROCESS-SCR. ACCEPT PROCESS-SCR.

 If so, then yes. Multiple ACCEPTs, since each program generally has at least 2 screens.

Is the ALLOWING MESSAGES FROM LAST THREAD necessary since I called the program without message?

Anyway, I tried adding the code to the first ACCEPT (SELECT-SCR), no success.

Then I added it to every ACCEPT, not working either.

Is the ACCEPT done at the very start of the program?


Do you mean something like this? 

DISPLAY SELECT-SCR. ACCEPT SELECT-SCR. ... DISPLAY PROCESS-SCR. ACCEPT PROCESS-SCR.

 If so, then yes. Multiple ACCEPTs, since each program generally has at least 2 screens.

Is the ALLOWING MESSAGES FROM LAST THREAD necessary since I called the program without message?

Anyway, I tried adding the code to the first ACCEPT (SELECT-SCR), no success.

Then I added it to every ACCEPT, not working either.

Is the ACCEPT done at the very start of the program?

The allowing messages isn't required. It is used when you want proga (in a thread) to inform progb (in a thread) of some information.

Try something like this:

call thread "Program1"

then see if the called program displays and allows you to interact with it.

No, an Accept can be anywhere, I just wanted to see if you programs were doing an accept versus using a thread to update the time on the first program.

 


The allowing messages isn't required. It is used when you want proga (in a thread) to inform progb (in a thread) of some information.

Try something like this:

call thread "Program1"

then see if the called program displays and allows you to interact with it.

No, an Accept can be anywhere, I just wanted to see if you programs were doing an accept versus using a thread to update the time on the first program.

 

There was a problem with the CALL EXCEPTION part. After I commented it, I can interact with Program1. But I still had to switch threads manually because the focus always stay in the last thread and not the new thread.

I can minimize Program1, go back to menu and open Program2. 

I can interact with Program2, but when I try to minimize, go back to menu or switch to Program1, the whole thing crashes.