locked
Phone stucks when executing thread.sleep RRS feed

  • Question

  • My application is developed with Windows Mobile SDK6.0. And it runs when the phone starts. But sometimes on windows mobile 6.5 based phones especially with Sprint, the phones stalls when it restarts. And according to the log, it was trying to execute thread.sleep(30000). Any idea why this occurs? 
    Wednesday, November 3, 2010 3:32 AM

Answers

  • If it's your application, then I would suggest putting that code in a separate thread. Then, only that thread would sleep, but your other threads could continue.

    -Paul

    Thursday, November 4, 2010 1:59 PM
  • Thread.Sleep() can't make your phone stop responding; at worst, it will make your application hang for the duration of the sleep. So, if your phone needs to be restarted in order to work, then that's probably not the direct cause of your issue.

    If you don't have your application in the startup folder, do you still have the same issue?

    If you wait for the phone to finish booting up and then start the application manually, do you still have the same issue?

    -PaulH

    Tuesday, November 9, 2010 2:18 PM

All replies

  • That command will make whatever thread is running stop and do nothing for 30 seconds. So, if your stall lasts for 30 seconds, that's why.

    As to why somebody would intentionally do this, I have no idea.

    -PaulH

    Wednesday, November 3, 2010 4:45 PM
  • The phone actually crashed and never recovered. Had to restart the phones. It works fine on Windows Mobile 6 and 6.1 but only with 6.5 for Sprint, we have this problem. Any idea why?
    Thursday, November 4, 2010 1:11 PM
  • As to why somebody would intentionally do this, I have no idea.

    -PaulH


    How about when the attempt of opening a port failed and we need to try again in 30 seconds? do you have any suggestion without calling thread.sleep?Thanks!
    Thursday, November 4, 2010 1:22 PM
  • If it's your application, then I would suggest putting that code in a separate thread. Then, only that thread would sleep, but your other threads could continue.

    -Paul

    Thursday, November 4, 2010 1:59 PM
  • The code already works like this. I put the thread.sleep into a sub thread and use autoeventreset in the main thread. However, the phone just stuck sometimes when it tries to execute this code. And this only occurs on 6.5 so far.

    Friday, November 5, 2010 5:48 AM
  • What do you mean the phone is stuck? Do you mean the Windows user interface won't respond (e.g. the start menu) or do you mean that your application's UI doesn't respond?

    -PaulH

    Friday, November 5, 2010 1:15 PM
  • The application's UI had no response and i had to remove the battery and put it back on in order to start the phone.
    Tuesday, November 9, 2010 2:20 AM
  • Thread.Sleep() can't make your phone stop responding; at worst, it will make your application hang for the duration of the sleep. So, if your phone needs to be restarted in order to work, then that's probably not the direct cause of your issue.

    If you don't have your application in the startup folder, do you still have the same issue?

    If you wait for the phone to finish booting up and then start the application manually, do you still have the same issue?

    -PaulH

    Tuesday, November 9, 2010 2:18 PM