How to improve WPF application performance

I developed a WPF application. In this application, iam uploads 200mb photos to the list. After that, Iam adds these images to the canvas. When adding photos to the canvas after a while (i.e., after adding the 10mb images) iam Getting Some error, for example ----

***** The CLR was unable to switch from the COM context 0x10b46f0 to the COM context 0x10b4860 for 60 seconds. A thread that owns the target context / apartment most likely either performs a non-download or processes a very long operation without pumping Windows messages. This situation, as a rule, has a negative impact on performance and may even lead to the application becoming inactive or memory automatically accumulating over time. To avoid this problem, all single-threaded (STA) threads should use transfer waiting primitives (such as CoWaitForMultipleHandles) and regularly send messages during long operations. *****

Is there a way to improve the performance of my application. I need a solution to this problem.

Any suggestions for this.

+3
source share
3 answers

Do not upload all 200 MB of photos to the list immediately in the user interface stream. Will the user watch 200 mb at the same time? This will take some work on your part, but you will need to do some delay in loading images from the background stream.

+5
source

Take a look at the article (Advanced Techniques To Avoid and Detect Deadlocks in .NET Applications), this may help.

+3
source

: -, , ; , COM. , STAThread WPF . MTA STA; WPF STA, .

, , ; . ListView / .

Here are some documents on using view-model . Viewmodel can coordinate image loading and provide ListView with a binding source that will automatically make the application work.

A simpler alternative could be to start a background thread and load images into an ObservableCollection <>, associate this with a ListView and let the structure work with the display.

I am the second that Greg D. said, downloading 200 mb of images sounds like a recipe for problems.

0
source

Source: https://habr.com/ru/post/1708809/


All Articles