In article <44c9a49b$0$15794$14726298@[EMAIL PROTECTED]
>,
"Hans Stoessel" <hstoessel.list@[EMAIL PROTECTED]
> wrote:
> I use Codewarrior 8.3 for the programming XTension for Quark.
>
> Now I have the following problem. I have to save a do***ent as a PDF and
> during the saving I have to wait in a loop until the PDF is finished. I
> can't do that
> in a while-loop because the PDF generation doesn't work in this case. I
have
> to give up processor time in the loop.
> - How can I do that?
> - The sleep-method is not available in Mac. Any other methods (time
> functions)?
> - Is there another possibility to give up processor time? If possible
> without threads....
> - Maybe I can release the event queue. How?
Are you writing a Carbon CFM plugin on OS X? You program can still use
system calls to load a Mach-O library, look up routines in it, and call
them. So if you wanted to, you could call sleep() in the
System.framework. The sample code here is useful:
http://developer.apple.com/samplecode/MoreIsBetter
If the pdf creation is done by a separate process,
http://developer.apple.com/technotes/tn/tn2050.html
may help, since it teaches you how to discover that another program has
finished, without polling.
File system changes can be detected using code from:
http://developer.apple.com/samplecode/FileNotification
If Quark uses a modern CFRunLoop, you can install CFRunLoopTimer so that
you can arrange to get called back when Quark is in a clean state, so
your code can "go to sleep" for awhile, and when it wakes up it can
operate without worrying that Quark will be in the middle of some
operation that keeps its services for plug-ins from functioning.
You shouldn't need to do this, though, you should be able to install a
Carbon Event handler for a custom event, one that uses your unique,
registered, 4-byte code
http://developer.apple.com/datatype/creatorcode.html
Then a callback, called potentially at interrupt time, from the above
sample code, can post a carbonEvent to trigger your main code.
Watch out: with appleEvents, if you sent to the magic process id { 0,
kCurrentProcess } the event would be sent as a procedure call, (without
queueing) while if you sent to the actual process id number, the event
would be enqueued on the event queue normally.


|