开发者

Touch-manipulation is freezing my udp-sending in Windows Phone 7.1 (Mango)

I have a weird problem with the Windows Phone 7.1 API. Im trying to write an app to send touch-delta from the touch-screen to move a mouse-pointer on a desktop-pc. Im using UDP-sockets but I have some performance-issues.

The sending of udp-messages seem to freeze for 0.5-1.0 sec every ~0.5 seconds or so. Im not sending huge amounts of data and Im throttling it as well. My latest attempt to find whats causing it turned out a bit unexpected.

When having a separate thread with a while-loop that keeps sending random-data everything works smooth and fine. But when I start touching the screen of the WP7-mobile I start getting these weird hiccups. I have removed all listeners on touch-events for debugging purposes and Im not doing anything else in my app then sending this data on a UDP-socket. But why is it freezing up like this when I move my finger over the screen? It kind of makes it impossible to write an app like this.

I've heard that touch-manipulation should be moved to a dedicated thread, is that included in the Beta2 refresh of WP7.1?

The code goes somewhat like this:

    new Thread(() =>
    {
        while (true)
        {
            _event.Reset();
            _socket.SendToAsync(_args);
            _event.WaitOne();
            Thread.Sleep(5);
        }
    }).Start();

The event-handle is set when SendToAsync is completed. So it keeps sending udp-data about every 5 ms. It works fine (I can receive in a steady and rapid rate) as long as I dont touch and drag my finger on the phone's screen. Then I start getting 1 sec freezings in regular intervals. Very strange since Im running the udp-firing on a separate thread. Is the CPU of the phone being overloaded in some way when its processing manipulation? Could that be causing the hiccups?


Update

I've refrased and updated this question in anothe开发者_如何学编程r thread to make it a bit more clear:

Poor UDP performance with Windows Phone 7.1 (Mango)


Everything runs on the UI thread till you push it to another thread. Most of my event handlers look like this

ThreadPool.QueueUserWorkItem(state => /* do stuff */);

I have Mango b2 and it is true that some stuff has been moved off the UI thread but this is erratic and it's easy to do it yourself.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜