About
The Cinema 4D Cinema API provides various functions to handle threads and thread related tasks.
- Warning
- 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.
{
{
}
doc->SetTime(BaseTime(time));
}
return OK
Definition: apibase.h:2740
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:69
#define CriticalStop(...)
Definition: debugdiagnostics.h:231
BaseDocument * GetActiveDocument()
maxon::Float Float
Definition: ge_sys_math.h:57
void EventAdd(EVENT eventflag=EVENT::NONE)
Bool GeIsMainThreadAndNoDrawThread()
const char * doc
Definition: pyerrors.h:226
- GeGetCurrentThreadCount(): Returns the number of threads being used for the current (render) context.
- IdentifyThread(): Returns the type of the current thread. Useful to get the current context.
- GeSleep(): Sleeps for the given time.
- StopAllThreads(): Stops all running threads. Needed when an asynchronous dialog reacts to a message (e.g. mouse click) and modifies the document. Never use this in a thread itself or in a function of a NodeData based plugin.
- StopDrawViewsThread(): Stops all draw view threads.
- GeStopBackgroundThreads(): Stops all running threads of the given class.
Running Systems
- Note
- CheckIsRunning() does not check if the current code is running within the context of the checked task. See IdentifyThread() above.
{
}
EXTERNALRENDERING
External rendering.
Definition: ge_prepass.h:3
#define BACKGROUNDHANDLER_TYPECLASS_C4D
Cinema 4D background handler type class.
Definition: ge_prepass.h:4903
RENDEREXTERNAL
External render.
Definition: ge_prepass.h:3
Bool CheckIsRunning(CHECKISRUNNING type)
Bool GeStopBackgroundThreads(Int32 typeclass, BACKGROUNDHANDLERFLAGS flags, BaseThread *thread)
Get Threads
These functions are used 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.
if (escThread == nullptr)
while (!escThread->TestBreak())
{
DoSomething();
}
BaseThread * GeGetEscTestThread()
Definition: c4d_thread.h:208
Further Reading