Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2007

    cancelInquiry hangs on S40 if called from synchronized block

    i have a problem on devices having S40 5th edition FP1. this is not a problem on S60:
    the problem is this:
    when you call the discoveryAgent's cancelInquiry method from within a synchronized block,
    it hangs. it is actually supposed to call back inquiryCompleted. the code simply freezes- never enters
    the inquiryCompleted method.
    if the same thing is done without the synchronized block - everything works.
    here's what my DiscoveryListenerlooks like:

    public class DeviceDiscoverer implements DiscoveryListener {
       private Object thisCannotBeInterruptedByOtherBlocksLikeIt=new Object();
       private DiscoveryAgent discoveryAgent;
       // <some irrelevant methods here. some have synchronized blocks like the one below >
       public boolean cancelInquiry() { //called from some controller when the user click cancel in mid discovery
          //synchronized(thisCannotBeInterruptedByOtherBlocksLikeIt) //problem when this is uncommented
              if (stillInCycle) {
                   //<some logic>
                   //<more logic>
       public void inquiryCompleted(int inquiryStatus) { //this is a callback in response to cancel or normal ending
          Beeper.beep(); //this makes the phone make a sound

    when you run the above code, with the synchronized statement commented out, on both s40 and s60,
    when the cancelInquiry method is called, immediately after that the inquiryCompleted method is called and you hear the beep.
    BUT, if you uncomment the synchronized statement, you hear the beep on S60 but on S40 (at least on 5th edition fp1)
    the inquiryCompleted is never called! (when i placed the beep stmt just before calling the discoveryAgent's cancelInquiry it beeped. when i placed it after that call, it didn't get there. that's because the call does not
    return until it calls inquiryCompleted and that call doesn't happen)

    what is the problem? if it's a bug in the impl'n of the cancelInquiry of S40, how do i get around it?
    i have to synchronize because things are done in parallel (for example my code may start an inquiry
    and then, may cancel it. at the time that it is cancelled the startInquiry may be running, deviceDiscovered may be running, inquiryCompleted may be running, and of course in parallel with any of these, the incoming cancelInquiry
    may be running.

    i tried to separate the inquiryCompleted into another listener instance, in other words, instead of calling
    discoveryAgent.cancelInquiry(this) i called discoveryAgent.cancelInquiry(anotherInstance) hoping that
    the inquiryCompleted in the 'anotherInstance' would be called but no, it hangs that way as well.

    any suggestions?
    thanks in advance

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    The Capital of INDIA

    Re: cancelInquiry hangs on S40 if called from synchronized block

    Just a quick guess as per your need, try to do this operation inside the different thread, and make sure that you are handling the inquiry in some other thread. Then probably this will be simple the job of making the two threads synchronized.
    Thanks with Regards,

    R a j - The K e r n e l

    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Registered User
    Join Date
    Mar 2003

    Re: cancelInquiry hangs on S40 if called from synchronized block

    Why do you want to synchronize cancelInquiry? Did not get it.

Similar Threads

  1. GetCallInfo() always fails when called party hangs up the call
    By stenlik in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2010-07-24, 15:31
  2. Synchronized block
    By rafaeldonato in forum Symbian
    Replies: 3
    Last Post: 2009-08-06, 16:13
  3. synchronized
    By widetech1 in forum Symbian
    Replies: 1
    Last Post: 2008-11-25, 20:41
  4. cancelInquiry() problem on Nokia 6600
    By hmauricio in forum Bluetooth Technology
    Replies: 6
    Last Post: 2007-02-06, 17:53
  5. agent.cancelInquiry
    By ssandor in forum Bluetooth Technology
    Replies: 1
    Last Post: 2005-05-09, 11:16

Posting Permissions

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