Two strategies comes to my mind (maybe others with more experience will
have better ideas):
* put both start_job()/end_job() in different thread, protect them with
Fl::lock()/Fl::unlock(), and after it gets completed, call
Fl::awake(NULL) to notify the main thread
* the second one is to put start_job() (with lock/unlock) protection in
separate thread and when it gets completed, let it call
Fl::awake(cleanup_cb), where 'cleanup_cb' is your callback (in the main
thread) with end_job() call; something like:
void cleanup_cb(void *o) {
Fl_Printer *p = (Fl_Printer*)o;
p->end_job();
}
void* thread_func(void *o) {
Fl_Printer *p = (Fl_Printer*)o;
p->start_job();
Fl::awake(cleanup_cb, p);
}
/* rest of the code */
Sanel
On 01/29/2013 02:10 PM, David Lopez wrote:
> Thanks, but then what should I do to avoid the blocking?
>
>> Have you tried to use locking described at:
>> http://www.fltk.org/doc-1.3/advanced.html?
>>
>> AFAIK, end_job() will access FLTK drawing facility again, which is
>> probably the cause why you are getting blocked UI again.
>>
>> Sanel
>>
>> On 01/28/2013 07:51 PM, David Lopez wrote:
>>> Hi everybody,
>>> I have a multi-thread FLTK 1.3 application on Win XP. The problem is that
>>> when the application tries to print (using Fl_Printer) all threads get
>>> blocked while the Windows printer selection dialog is open. In that case
>>> the method Fl_Printer::start_job() was called from a callback (from main
>>> thread).
>>> So to prevent the application from blocking I decided to create a working
>>> thread that calls Fl_Printer::start_job() … Fl_Printer::end_job().
>>> With this change, the application doesn’t block itself while the dialog
>>> is open but blocks forever after printing.
>>> I suspect that I’m doing something wrong since I know that no window
>>> should be open or close from threads other than the main one, but I don´t
>>> know what would be the right way to implement this.
>>> Thank you very much.
>>> David
>>>
>>
>
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk