Parallel Threading vs Serial Threading in Mechanical ACT

Options
Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 411
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer

Parallel Threading vs Serial Threading in Mechanical ACT

Comments

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 411
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    edited October 2023
    Options

    Parallel Threading: The control moves over to the rest of the code, while part of the code is executed in a parallel thread.

    Please note the "," after the 2nd argument is crucial.

    Example:

    import threading
    msg_string = "Test String"
    
    def show_info(message):
        MessageBox.Show(message)
    
    thread = threading.Thread(target=show_info, args=(msg_string,))
    thread.start()
    

    Serial Threading: The control pauses till the user clicks OK in the MessageBox but the set of commands is executed in a separate thread.

    Example:

    msg_string = "Test String"
    
    def show_info(message):
        MessageBox.Show(message)
    
    ExtAPI.Application.InvokeUIThread(show_info, msg_string)