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 / CodeWarrior / July 2006



Tip: Looking for answers? Try searching our database.

Waiting time during process

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hans Stoessel - 28 Jul 2006 06:48 GMT
Hi

I use Codewarrior 8.3 for the programming XTension for Quark.

Now I have the following problem. I have to save a document 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?

Thanks a lot for any help

Regards
Hans
David Phillip Oster - 28 Jul 2006 16:13 GMT
> I use Codewarrior 8.3 for the programming XTension for Quark.
>
[quoted text clipped - 9 lines]
> 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.
 
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.