Friday 15 May 2015

kinect - c# WPF UI freeze after using MemoryStream -


I have some problems with this code:

  Write a private bitmap bitmapotetemap (writeable Bilmap wb) {bitmap encoder encoder = new BMPBitmap encoder (); Encoder.frames.Add (BitmapFrame.Create (WB)); (Using memorystream ms = new memorystream ()) {encoder. Save (ms); Bitmap b = new bitmap (ms); Return b; }}   

If I start this code, then the WPF UI is freeze. I want to convert only a WriteableBitmap to bitmap so that I can use it for emu image processing. Wroteable bitmap is made from Kinect from Depthdata. I'm new in programming, so this is definitely a better way, but I hope this will also work.

Can anyone help me with that code?

It's a little late, but I want to add some more information.

The problem is that you are using a synchronous call that uses the UI thread, unlike all other synchronous calls, this call takes some time, and therefore, until the call is not finished Once it's done, your app stabilizes.

You need to use an asynchronous call so that your UI thread will be free, so the UI will not be frozen.

There are several ways to make asynchronous calls, like opening a new task, thread, or waiting for a better way of waiting async, which is very good - you can write a synchronous code , And async and can wait in the right places, and sentences - this is an asynchronous code!

Click to know more about async.

No comments:

Post a Comment