THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 20/11/2009 at 12:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.528
Platform: Windows ;
Language(s) : C++ ;
---------
I'm trying to run a render asynchronously in the background, much like C4D's Make Preview command. I've got the render running in a separate thread, but it seems a Wait command is necessary to get the thread to process the render. Once I add the Wait though, it locks the GUI. I've found several examples here for synchronous render processes, but none for async renders. My (simplified) code is below. Any tips?
class AlioSeqThread : public C4DThread
{
private:
BaseDocument* m_doc;
BaseBitmap* m_bmp;
BaseContainer rdbc;
AlioSeqProgressData pd;
public:
AlioSeqThread(BaseDocument* adoc, BaseBitmap* abmp, BaseContainer bc, AlioSeqProgressData apd) { m_doc = adoc; m_bmp = abmp; rdbc = bc; pd = apd;} //constructor
virtual ~AlioSeqThread() { m_doc = NULL; m_bmp = NULL; End(); Wait(FALSE); StatusClear();} //destructor
virtual void Main(void);
virtual Bool TestDBreak();
virtual const CHAR *GetThreadName(void) { return "AlioSeqThread"; }
};
void AlioSeqThread::Main(void) {
LONG result = RenderDocument(m_doc, rdbc, AlioSeqProgressHook, &pd;, m_bmp, RENDERFLAG_EXTERNAL|RENDERFLAG_SHOWERRORS, this->Get());
}
Bool AlioSeqThread::TestDBreak() {
BaseContainer keyinput;
if(GetInputEvent(BFM_INPUT_KEYBOARD, keyinput) && (keyinput.GetLong(BFM_INPUT_CHANNEL) == KEY_ESC)) GePrint("esc");
return (GetInputEvent(BFM_INPUT_KEYBOARD, keyinput) && (keyinput.GetLong(BFM_INPUT_CHANNEL) == KEY_ESC));
}
class AlioRenderSeqCommand : public CommandData
{
public:
virtual Bool Execute(BaseDocument *doc) {
BaseDocument *rdoc = (BaseDocument* )doc->GetClone(COPY_DOCUMENT, NULL);
AlioSeqThread ast(rdoc, bmp, rdbc, pd);
ast.Start(TRUE, THREADPRIORITY_BELOW);
ast.Wait(TRUE);
BaseDocument::Free(rdoc);
return TRUE;
}