Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

WPF - Can it not perform in fast situations?

Back to Forum: Tech Off
  • User profile image
    Guard

    I'm working on a project using an Ultrasound machine, with a WPF implementation.

    The system collects an image, I recieve the data in a callback, (for now) convert it to a System.Drawing.Bitmap (the old way i was doing it), do some minor drawing on it, send it out through an event, and then copy the bits directly into a BitmapSource I create at the start of the app. I copy the bits using a BitmapBuffer class I found online as a suggestion to get better image performance in WPF: http://jmorrill.hjtcentral.com/Home/tabid/428/EntryID/16/Default.aspx

    Everything works great to a point. Using stopwatches, I can time and see how long everything takes. The creation and display of the images happens through events, where the creation of the Bitmap takes 5ms, the copying of the bits takes 1ms, and the whole process of taking the original bitmap and getting it on the screen estimates around 11ms. If the last frame isn't completed (the event handler has to trigger that the frame has been handled), it would ignore the next frame that comes in, but this is never the case because of the fast completion.

    Here's the problem: This works great at a low framerate, or even up to around 20fps. When I start to get faster, for example, around 40fps, the entire interface seems to freeze, where the image isn't updating, sliders don't move, and so on. At this point, frames are coming in about every 25ms, and i'm still processing them in about half this time. Strange this is, if you trigger a MouseOver event on any button on the screen (even when they dont have MouseOver events handled), it unfreezes everything for a while. Frames are still processing in the background (as visible through a Debug.WriteLine), it is only the visual aspect of the page that is freezing.

    Any ideas of what could be causing this, or is WPF not able to handle such high framerates? As far as I know, it should be doing the image handling on a seperate thread, and there don't seem to be any issues until the framerate becomes high (which is a very likely situation for someone using this).

    Any help would be appreciated, Thanks!

  • User profile image
    Guard

    Looks like it may have been a problem with the design of the XAML. Our design team gave us a new interface to work with, and it seemed to fix the problem. Still seems odd to me that it happened in the first place, but I suppose as long as it works Smiley

    I'm guessing from the long amount of replies I got, no one else had any idea what could cause it either.

  • User profile image
    phreaks

    Why would an ultrasound machine need 40 fps?

    My wife recently had one, and I noticed it was 15 fps, and it seemed adaquete.

  • User profile image
    tamir

    Currently I'm drawing 848X480@40fps MPEG Layer-3 video with 160kBps audio in regular MediaElement. The UI responses, but it's impossible to do something else in the system.
    The workaround was to draw video, using DirectShow directly over other window handler and put transparent WPF window over it for processing. In this case, everything works fine at less then 10% CPU.

    You can look into my blog for more information about it

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.