Get Main Thread [SOLVED]



  • On 09/01/2017 at 00:33, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R18 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hello.

    Is there any call that will allow me to get Active thread as I do with GetActiveDocument ?
    Is it safe to use it to process something  from a non-main thread?

    Example: Run BakeTexture(...) using the main thread from a non-main thread.

    Thank you.



  • On 09/01/2017 at 04:27, xxxxxxxx wrote:

    Hi Peterakos, thanks for writing us.

    With reference to your first question, there are a few utility calls that might be worth looking to obtain certain threads:

    • GeGetCurrentThreadId(): returns the unique ID for the current thread;
    • GeGetCurrentThread(): returns the current BaseThread. This BaseThread can be passed to functions that require a BaseThread argument to check for stop conditions;
    • GeGetDummyThread(): returns a dummy thread. This may be used when a BaseThread argument must be set;
    • GeGetEscTestThread(): returns a thread for escape key testing. This may be used when a BaseThread argument must be set.

    With reference to your second question, well I'd say it strongly depends on what you expect to process so better circumstancing your question will be helpful. In BakeTexture, for example, passing the object returned by the GeGetEscTestThread() will provide you with some helpful means to interrupt the baking computation by pressing Esc.

    Best, Riccardo



  • On 10/01/2017 at 07:27, xxxxxxxx wrote:

    Hello and thank you very much for this information.

    I assume it's safe to use GeGetCurrentThread() as thread parameter in BakeTexture, if we want the current thread to be blocked until the texture baking is done right ?

    Thank you very much.



  • On 11/01/2017 at 07:55, xxxxxxxx wrote:

    Hi Peterakos,

    the BaseThread object to be passed as parameter in the BakeTexture() is used to test for a break and should be the returned from GeGetEscThread which actually helps quitting the texture baking process prematurely by pressing Esc button.

    Best, Riccardo


Log in to reply