iEinstein
iEinstein

Reputation: 2100

KeyBoard Hangs While Typing

First Of All Happy New Year to all of you.

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.

Thanks

Upvotes: 0

Views: 532

Answers (2)

rob mayoff
rob mayoff

Reputation: 385600

You need to either use non-blocking, asynchronous functions/methods to send the message, or you need to send the message on a dispatch queue or an operation queue.

Both of these queue types are discussed in Apple's Concurrency Programming Guide.

You can also watch some Apple developer videos about concurrency:

Upvotes: 4

P.J
P.J

Reputation: 6587

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.

EDIT : For sending message you should use NSThread

Upvotes: 1

Related Questions