Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / July 2006



Tip: Looking for answers? Try searching our database.

Waiting for a callback in a loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hans Stoessel - 31 Jul 2006 10:16 GMT
Mac OS X
Codewarrior 8.3
QuarkXTension

Hi

In my XTension I start a PDF export in a class (e.g. name ClassA) using the
Quark-SDK function xtpdf_export. This method doesn't wait until the PDF is
created. It comes back immediately. If the PDF is finished, a callback
routine in another class (e.g. ClassB) of my XTension is called. Now I have
to wait in ClassA (where the PDF export is started) until the PDF is
finished (in the callback routine in ClassB is a flag set in that case). I
like to wait in a while-loop until the flag in the callback routine is set.
But if I do that the export is not started because the while-loop need all
time (I
suppose) or blocks the PDF creation on another way. I release the message
queue in the loop, but this doesn't work.

How can I solve this?
Is there something like "sleep the loop" that doesn't block all other
things?

Thanks
Hans
Patrick Machielse - 31 Jul 2006 10:23 GMT
> In my XTension I start a PDF export in a class (e.g. name ClassA) using the
> Quark-SDK function xtpdf_export. This method doesn't wait until the PDF is
[quoted text clipped - 6 lines]
> time (I suppose) or blocks the PDF creation on another way. I release the
> message queue in the loop, but this doesn't work.

Rather than wait in ClassA, can't you move the post-pdf-creation code to
a new method and call that from your callback routine in ClassB?

patrick
Hans Stoessel - 31 Jul 2006 10:56 GMT
Hi

Yes, I can move the post code into the callback routine. But is that the
solution? Thne I have to wait in the callbck routine and the application is
blocked.

ClassB has a loop where are several pdf exports are done. But I can't do a
pdf export in this loop while another pdf export is running. Thats because I
have to wait until the callback in ClassA is called, means the pdf export is
finished. Then I can do the next export. Its quite tricky I think.

Maybe I can start the export in ClassA and wait after that for a specified
event. In my callback routine in ClassB I send the event if the pdf is
finished? Possible? How? During the waiting for the event the application
may not be blocked!

Thanks
Hans

>> In my XTension I start a PDF export in a class (e.g. name ClassA) using
>> the
[quoted text clipped - 17 lines]
>
> patrick
Patrick Machielse - 31 Jul 2006 11:55 GMT
> ClassB has a loop where are several pdf exports are done. But I can't do a
> pdf export in this loop while another pdf export is running. Thats because I
> have to wait until the callback in ClassA is called, means the pdf export is
> finished. Then I can do the next export. Its quite tricky I think.

OK, now you're providing new information...

So you need to do a number of asynchronous pdf exports in ClassB. I
would make ClassB maintain a stack of export tasks. Start the export of
the top task in the export method you call from ClassA. In the ClassB
callback you can simply call the export method again to process the next
task. When the stack is depleted, you can call the ClassA callback.

patrick
Hans Stoessel - 31 Jul 2006 13:19 GMT
Hi Patrick

Thank you very much for the answer.

This way doesn't solve my problem. I can't build a stack from export tasks
because the Quark document (QXP) has to be open for the export. This means I
have to open the Quark document, export it as a PDF and close it again. I
open the Quark document in ClassB and call the method xtpdf_export to export
it as PDF. Then I have to wait until the callback function in ClassA (PDF
finished) is called from the export method xtpdf_export. After the callback
is called, I can close the document (QXP). If I close the document before
the PDF is finished, the XTension crashs. Thats the reason I have to wait in
a loop. When I wait, the xtpdf_export calls the callback "PDF export
started", but after that no callback method is called. I don't know why. On
Windows this works fine, on Mac OS X not.

Regards
Hans

>> ClassB has a loop where are several pdf exports are done. But I can't do
>> a
[quoted text clipped - 13 lines]
>
> patrick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.