Thread Utility Manual


The Cinema 4D classic API provides various functions to handle threads and thread related tasks.

For MAXON API threading utilities see Threads Manual.

Utility Functions

Various tasks should only be performed from the main thread. For example any GUI interaction or any change of the currently active BaseDocument must only happen from the main thread. To make sure that such code is only executed in the main thread the following functions can be used:

  • GeIsMainThread(): Returns true if the code is running in the context of the main thread.
  • GeIsMainThreadAndNoDrawThread(): Returns true if the code is running in the context of the main thread and if the main thread does not execute any viewport drawing.
// This example shows how a context less function can check
// if it is allowed to edit the active document.
static maxon::Result<void> SetActiveDocumentTime(const Float time)
// check if the function is called
// from within the main thread
if (doc == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
return maxon::OK;
BaseDocument * GetActiveDocument(void)
void EventAdd(EVENT eventflag=EVENT::NONE)
Bool GeIsMainThreadAndNoDrawThread()
Definition: c4d_basedocument.h:498
Definition: c4d_basetime.h:25
maxon::Float Float
Definition: ge_sys_math.h:66
return OK
Definition: apibase.h:2667
Definition: memoryallocationbase.h:67
#define CriticalStop(...)
Definition: debugdiagnostics.h:237
const char * doc
Definition: pyerrors.h:226

Running Systems

CheckIsRunning() does not check if the current code is running within the context of the checked task. See IdentifyThread() above.
// This example checks if the external render thread is running.
// If so it should stop.
// check if the external renderer ("Picture Viewer") is running
Bool CheckIsRunning(CHECKISRUNNING type)
Bool GeStopBackgroundThreads(Int32 typeclass, BACKGROUNDHANDLERFLAGS flags, BaseThread *thread)
Cinema&#160;4D background handler type class.
Definition: ge_prepass.h:4866
Render external.
External rendering.

Get Threads

These functions are used to obtain certain threads:

// This example will execute the while loop until the "Esc" key is pressed.
BaseThread* const escThread = GeGetEscTestThread();
if (escThread == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// execute the loop until the escThread signals to stop
while (!escThread->TestBreak())
BaseThread * GeGetEscTestThread()
Definition: c4d_thread.h:208
Definition: c4d_thread.h:28
Bool TestBreak(void)
Definition: c4d_thread.h:39

Further Reading