Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!Urd!newsuser From: sund@tde.lth.se (Lars Sundstr|m) Newsgroups: comp.sys.mac.programmer Subject: Re: DA loses resource file on accRun Message-ID: <1989Jul19.231814.6163@lth.se> Date: 19 Jul 89 23:18:14 GMT References: <1989Jul17.045641.20314@lth.se> Organization: Lund Institute of Technology, Sweden Lines: 58 In article time@oxtrap.UUCP writes: >In article <1989Jul17.045641.20314@lth.se> sund@tde.lth.se (Lars Sundstr|m) writes: >> >> I'm developing a desk accessory which reads a resource >> file continuously. When the DA is running as a foreground >> task it periodically receives accCursor events which >> is used for reading a couple of resources. So far so good. >> >> However when running in the background the DA only receives >> accRun events and the DA can't reach the resource file because >> UseResFile(myResFile) gives ResError=-193 "resource file not found". >> It seems to me that when the DA receives accRun events its called >> without a context switching but I don't know for sure. >> >> Does anyone know what's the problem here? >> >Assuming you are under MultiFinder... Yes >1) Your "myResFile" is wrong. > I assume you checked this. As soon as the DA runs in the foreground everything works fine. > The fix: > * Migrate the resources to the system file. > * Keep resources in memory. > I assume you can't, thus the reason for the problem. > * Open and Close the resource file around the reads. > Boy, here's a performance beast. > * Don't use resources. Use an open file and struct's. > The format of the resource file that has to be read is already defined and all resources together are to big to be kept in memory. But since the problem only occures when under MultiFinder I could use some of the global space provided by the MF Temp. Memory Allocation in conjuction with Open and Close the resource file. Thus I could maybe read 10 resources instead of one every time the file has to be opened. I give it try. I assume that I can't do a context switch of my own to return to environment as seen by the DA at all other events except accRun. >BTW: I would use accRun for ALL cases. accCursor is very unreliable >for periodic action, and too much overhead when the cursor is flying >about the DA's window. Of course, you may have very good interface >reasons for this approach. > >So, this was a lot of rambling. Hope it contains a good pointer. > >Tim. Thanks Lars