Write an asynchronous method

Login to reply to this topic.
Wed, 2005-08-24 16:43
Joined: 2005-06-14
Forum posts: 81
Hello,

I would like to know how to write an asynchronous method. In fact IÂ’m using a CActive Object with a method that check all entries of the CContactDatabase and I would like to set it as asynchronous method so that it can continue the operations without waiting for its end.

This is my method :


void CMyCActive::SearchContactAsyn( const TDesC & aNumber, TRequestStatus& aStatus )
{
 
  SetActive();
 
//My code that search a contact
.....

}


The problem is that it doesnÂ’t run asynchronously and the whole application is waiting after it.

If anyone knows please let me know.

Thank you very much,

Bernie

Wed, 2005-08-24 16:59
Joined: 2005-07-28
Forum posts: 121
Re: Write an asynchronous method
place your code inside the RunL(), also break down the search into steps - basically create a state machine

In your search function call your own runl

TRequestStatus* ptr = &iStatus;
iStatus = KRequestPending;
SetActive();
User::RequestComplete(ptr, KErrNone);


Don't forget to store the clients aStatus value, and when your finished you inform the client that the search is over with
User::RequestComplete(iClientStatus, KErrNone);
  • Login to reply to this topic.