Click here to Skip to main content
15,881,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating a windows Phone 7 application. I want to freeze the UI for a few seconds. Should I use a timer? Calling the Thread.sleep() method isn't giving the proper result. Which timer should I use? Can someone give proper explanation?
Posted
Comments
I.explore.code 26-Oct-11 10:14am    
its actually funny how easy it could be to freeze the GUI when you don't want it to freeze and vice-versa otehrwise :)

If I am not misunderstood, you want to put some delay between your Operations.

For this in WP7 Programming, use DispatcherTimer.

Have a look at below links.
http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer.aspx#Y0

http://social.msdn.microsoft.com/Forums/is/windowsphone7series/thread/a7509566-7d13-483e-bf3a-3ce22dcba1f6
 
Share this answer
 
Comments
BobJanova 26-Oct-11 11:21am    
This looks like the right answer for imprecise, UI related timed operations.
RaisKazi 26-Oct-11 13:10pm    
Thank you Bob :). Both yours and mine guess was correct. :)
Espen Harlinn 26-Oct-11 20:08pm    
5'ed!
RaisKazi 27-Oct-11 0:51am    
Thank you Espen. :)
Can you not just disable all your controls on the GUI for the amount of time you don't want any UI interactions and place a simple "Please Wait" thingy on the GUI?
 
Share this answer
 
Comments
Mark Salsbery 26-Oct-11 11:02am    
Agreed. That would be my solution. You shouldn't be halting the UI thread on WP7 (or Silverlight or WPF)...
BobJanova 26-Oct-11 11:19am    
... or any other platform ;)
VigneshPT 26-Oct-11 11:24am    
Accepted. But my question was actually about how exactly do I disable things for a particular amount of time. I think I found the answer, but suggestions are welcome.
I.explore.code 26-Oct-11 11:31am    
sounds good if you have found a solution, if you get stuck again. Do come back :)
Why would you want to do that? Normally, the problem is not freezing the UI...
Why would you want to deliberately let the user think the phone has crashed for no good reason?
 
Share this answer
 
Comments
VigneshPT 26-Oct-11 10:00am    
Intention is not to make the user think that the phone has crashed. All I want to do is to enable visibility of a picture for two seconds, and make it invisible after two seconds(i.e., before repainting my display). All user interaction is to be ignored during this time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900