Jump to content

Many processes against a Gui, Serial or parallel processing?


Gianni
 Share

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)
GUISetState(@SW_SHOW)

; 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
Next
Sleep(1000)
WinActivate($hGui)
MsgBox(0, "Pause", "Waiting for Godot...") ; just stay in pause and idle
GUIDelete($hGui)
Exit
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")
    Next
    Return $aGuiControls
EndFunc   ;==>_GUICtrlsMatrix_Create

Func End()
    If WinActive($hGui) Then
        GUIDelete($hGui)
        Exit
    EndIf
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 ****
#AutoIt3Wrapper_Change2CUI=y
#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)
    Exit
EndIf
; -----------------------------------------------------------------------
; _ArrayDisplay($CmdLine) ; Debug: Check received parameters
SRandom(@MSEC)
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)))
    Next
WEnd

 

Thnks for answers

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
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.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...