I am working on Chat Application My problem is that when i send a message to another user if i type another message while previous is going to other my keypad hangs for some time.When First message get delivered then keyboard comes in normal state from hanged state and the character i have typed get appeared.

Can anyone suggest me what to do to prevent keyboard from hang.Any Suggestion would be appriciated.

2 Answers
2

Use NSThread as you want a unit of computational work done without necessarily either waiting for other units to finish, or holding up other computational work.

You can put almost any work into a thread, if it is sensible to do so.

A good example is a network request, where you set up a thread to download data from, say, a web server. Your thread will fire a "handler" function when it has completed its work. The handler works with the downloaded data; for example, parsing XML data from a web service.

You would use a thread in this example, because you don't want the entire application to lock up while your app downloads data over the network and processes it. An NSThread instance puts this unit of work into its own little "space" that allows the larger app to continue to interact with the user.

An example of where you do not want to use threads on the iOS platform is with UI updates (e.g., changing the state of any of the UIControl widgets). All UI updates happen on the main thread. If you use your own threads with UI widgets, the behavior is unpredictable and, more often than not, will simply not work.