THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 28/01/2005 at 11:47, xxxxxxxx wrote:
You call AddBackgroundHandler() when you want to add a background handler. It can be called anywhere you want, though I'm not sure if you can call it from a thread.
You call RemoveBackgroundHandler() to remove handlers. I think it can be called at the same places as above.
You call Stop() to stop handlers of a given typeclass. Yes, call it whenever you want.
Yes, I think so.
No. This is called by CINEMA 4D when it is idle. It checks with the background handlers if they have something to do. Normally you don't need to call it yourself.
Anything you want. It will be sent to your hook.
Yes.
No. No.
The background handler cannot be a regular class function. Possibly it could be a static class function, if the compiler allows it. Here's a sample hook:
Bool Handler_ActiveMaterial(void *data, LONG command, LONG flags)
{
switch (command)
{
case BACKGROUNDHANDLER_ISRUNNING:
{
return world->materialpreview && world->materialpreview->IsRunning();
} break;
case BACKGROUNDHANDLER_STOP:
{
if (flags&BACKGROUNDHANDLER_FLAGS_MATERIALPREVIEW)
{
if (world->materialpreview)
world->materialpreview->End();
}
} break;
case BACKGROUNDHANDLER_START:
{
return CheckActiveMaterialPreview(world->GetActiveDocument());
} break;
}
return TRUE;
}
BACKGROUNDHANDLER_ISRUNNING
|
Return _<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#true1"_>_ color=#0000ff TRUE if the handler is currently running, otherw_<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#false0"_>_E0"> color=#0000ff FALSE.
BACKGROUNDHANDLER_STOP
|
Stop the current activity._<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#true1"_>_#TRUE1"> color=#0000ff TRUE when the activity has stopped.
BACKGROUNDHANDLER_START
|
Check if there's something to do. If _<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#false0"_>_tml#FALSE0"> color=#0000ff FALSE. In case there's something to do, directly start this_<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#true1"_>_s82.html#TRUE1"> color=#0000ff TRUE. There's also the possiblity to do a small job synch_<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#false0"_>_ants82.html#FALSE0"> color=#0000ff FALSE (pretend as if nothing was started).
Note: As the background handler is processed in the main application thread this means that if you process something un-threaded the complete application will be blocked. E.g. some code that takes 10 seconds means that the user will not be able to click on any button or stop anything during that time. That's why only extremely short tasks must be directly processed, otherwise start an asynchronous thread.
BACKGROUNDHANLDER_REMOVE
|
The handler i_<_a class=silent href= "mk:@msitstore:c:\program\cinema%204d\v8sdk\c4dr91sdkchm2005-01-25.chm::/pages/ge_math/enum_boolconstants82.html#true1"_>_Constants82.html#TRUE1"> color=#0000ff TRUE.