Jump to content
Sign in to follow this  

Many processes against a Gui, Serial or parallel processing?

Recommended Posts

Good morning,

what I would to understand is:
1) There are many processes that are running at the same time, they try to access the Labels located on a Gui belonging to another main process, and change the contents of various Labels.
2) The process that holds the Labels, makes no processing, but should only passively receive the updates of the labels performed directly by the other processes running separately.
3) Therefore, the "Main" script generates just 1,000 controls of type "Label" on his Gui, then it spawn several independent processes, passing to each one of them through the command line, references to his labels that it must manage, then it simply remains idle and on pause.
4) On the other side, spawn processes performs separate updates to the Label controls located on the Gui of the main process.

now the question is:
The various processes running independently, will update the labels on the Gui of the Main process, one after one or in parallel?

the system I've written here as test as a whole works, but how can I tell if the label controls are updated in parallel or in serial?

and if it is updated in serial mode, then where is the bottleneck?

Before you run the script Main, you have to compile the TX script  As TX.exe

Main script: (it generates a matrix of labels on his gui and then spawn other separate processes)

#include <Array.au3>
Local $Step = 200; number of "Label" reference passed to separate processes
HotKeySet("{Esc}", "End")

; Create a GUI containing a matrix of little squares (made by "Label" controls)
Local $hGui = GUICreate('Test', 810, 330)
GUISetBkColor("0x9A9A9A", $hGui)

; create the "panel" of labels within the GUI. All IDs of the labels are returned in an Array
Local $aGuiCtrlsMatrix = _GUICtrlsMatrix_Create(5, 5, 50, 20, 15, 15)

; now spawn some "external" processes that should updete the labels
Local $Parameters
For $i = 0 To UBound($aGuiCtrlsMatrix) - 1 Step $Step
    ; generates the string containing the group of label's IDs to be passed as parameter to the spawn process
    $Parameters = StringStripWS(_ArrayToString($aGuiCtrlsMatrix, " ", $i, $i + $Step - 1), 7)
    $Parameters = $hGui & ' ' & $Parameters ; insert the handle of the Main window as a further parameter
    ConsoleWrite($Parameters & @CRLF) ; Debug: show the $parameters on console
    Run('.\TX.exe ' & $Parameters) ; ,"",@SW_MINIMIZE) ; Spawn processes and pass parameters
MsgBox(0, "Pause", "Waiting for Godot...") ; just stay in pause and idle
Func _GUICtrlsMatrix_Create($xPanelPos, $yPanelPos, $nrPerLine, $nrOfLines, $Width, $Height, $xSpace = 1, $ySpace = 1)
    Local $aGuiControls[$nrPerLine * $nrOfLines];,$aPanelParams[]
    For $i = 1 To $nrPerLine * $nrOfLines
        $row = Int($i / $nrPerLine) + Not (Not (Mod($i, $nrPerLine)))
        $col = $i - ($row * $nrPerLine - $nrPerLine)
        $left = $xPanelPos + (($Width + $xSpace) * $col) - ($Width + $xSpace)
        $top = $yPanelPos + (($Height + $ySpace) * $row) - ($Height + $ySpace)
        $aGuiControls[$i - 1] = GUICtrlCreateLabel("", $left, $top, $Width, $Height, 0x01) ; 0x01 -> center text in the label
        GUICtrlSetBkColor(-1, "0xFFFFFF") ; "0x757575")
        ; GUICtrlSetTip(-1, "Control " & $i & @LF & "Row:" & $row & " Col:" & $col & @LF & "Empty")
    Return $aGuiControls
EndFunc   ;==>_GUICtrlsMatrix_Create

Func End()
    If WinActive($hGui) Then
EndFunc   ;==>End


TX script (it will update labels located on the main process) it must be compiled as TX.exe before running the Main script.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; -----------------------------------------------------------------------
; riceves parameter (IDs references to labels on Main process)
If Not $CmdLine[0] Then
    MsgBox(0, "Error", "Missing parameters" & @CRLF & "Exit in 5 seconds", 5)
; -----------------------------------------------------------------------
; _ArrayDisplay($CmdLine) ; Debug: Check received parameters
While 1 ; infinite loop to continuously update labels on Main process with random ascii chars
    For $i = 2 To $CmdLine[0] ; start from 2 to skip HWnd
        ControlSetText(HWnd($CmdLine[1]), "", "[ID:" & $CmdLine[$i] & "]", Chr(Random(33, 127, 1)))


Thnks for answers

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post

Link to post
Share on other sites

TX.exe updates labels sequentially / serial

Each of those updates at the same time / parallel 

Any bottle neck with be the main process handling its window message queue.

Share this post

Link to post
Share on other sites

Thanks JohnOne for the answer.

Hmmm.... so,  the message queue of the main process window is the bottle neck...
(....as already pointed out by Melba23 in this previous Topic, but it was not very clear to me the cause of the bottle neck. (my fault))

Well thanks JohnOne for clearing the point.

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...