×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Sep 2004
    Posts
    51

    Waiting for a CActive object to finish

    Hi,

    I have a class derived from CActive class.
    Is there a way to specifically wait on an instance of the class?

    I found CActiveScheduler::WaitForAnyRequest() which I assume I can use to wait continuosly, and each time it returns I can check my object. Is that a good idea? Can I assume the scheduler I get from CActiveScheduler::Current() contains my CActive object.

    I also thought about using User::WaitForRequest() but I'm not sure how I connect the speicifc TRequestStatus with my CActive object.

    Any comments will be appreciated.

    Thanx
    Yaron Tadmor

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    basically you just gibe the iStatus variable as an argument to the wait.

    anyway, it is advisable to not use this method too much, since it is blocking the whole application tread while waiting.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Sep 2004
    Posts
    51
    OK.
    Let me describe what I want to do and maybe you can direct me in the right direction.

    I have a rather long operation, which reads a sequence of bitmaps and processes them. I want to have a simple loop in which each iteration reads 1 bitmap and processes it.

    I'm using a CImageDecoder for the read. After I call it's Convert() method, I need to wait for the async operation to complete. How do I do that? Is is possible to do it without leaving my function and loop.

    I also have a general question regarding async operations. Which thread runs these operations? How and when do they get scheduled? Is there any in depth document of symbian's threading and event handling mechanisms?

    Thanx
    Yaron Tadmor

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    I', quite sure you can do it in standard AO way, just have some sort of array made, which you process one by one, while keeping in memory which one of the items you are currently working with. then you just wait in your RunL when one round is ready and increase the count of processed loops there.

    Basically AO's are scheduled inside the tread they are called in. There is a quite good document in decoments section descriping AO's and active scheduler, as well as the concepts are explained quite well in many of the symbian books available.

    yucca

  5. #5
    Regular Contributor
    Join Date
    Sep 2004
    Posts
    51
    Well, I'll try it this way. I was hoping there could be an easier way of waiting on a status object.

    I tried this code:
    {
    CFbsBitmap *bitmap = new CFbsBitmap;
    bitmap->Create(TSize(0,0), EColor256);
    TFrameInfo frameInfo;
    CImageDecoder *loader = CImageDecoder::FileNewL(m_sessionFs, aFileName);

    frameInfo = loader->FrameInfo(aSelectedFrame);
    TRect bitmapSize = frameInfo.iFrameCoordsInPixels;
    bitmap->Resize(bitmapSize.Size());

    TRequestStatus stat (KErrNone);
    loader->Convert(&stat, *bitmap, aSelectedFrame);
    User::WaitForRequest(stat);
    }

    The wait never returns! As I understood the async request to CImageDecoder::Convert() should complete eventually, shouldn't it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×