Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Creating a WPF window and open its dialog asynchronously on button click.

$
0
0

I have a WPF App in which i have to open a new WPF window on a button click asynchronously as it takes a while due to long running process.

I tried to create a Task an tried to open Window on Task.Run(). But that gives me an exception that it must be an STA operation and requires all UI Components.

After searching i found that u cannot do UI related operation in Task.Run() as it is Multi-Threaded Apartment operation.

Some suggested to create a new Thread for creating a new WPF window.

So, I would like to know how to achieve this and best way for this? Shall i create a new Thread or it can be done via Task?

Regards

Shailesh Aggarwal


Viewing all articles
Browse latest Browse all 18858

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>