开发者

Skipping a command when app is freezing

How can I handle the problem when in my app somebody set a wrong IP address to socket communication? The app is freezing at line, where the so开发者_如何转开发cket is waiting for answer from the server. (i'm using SmallSockets) Is it posible to make a timer for this command, and after the timer count down skip this command?


You shouldn't be handling synchronous network communications on the main thread. You should be doing networking stuff asynchronously. Here's an example that should get you going.

Using an asynchronous approach, you should be able to cancel a network operation after a timeout easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜