I have WPF application with a combobox filled with Users, a grid showing some data for the selected User and a button that calls DoTimeSheetReport().
DoTimeSheetReport() does some work and then opens a new window with a SSRS report. Everything works fine but the method takes a long time to complete, mostly because of the report, which means my UI becomes unresponsive. I tried a couple of ways to start a new thread/task but all of them are blocking the UI's thread. I'm probably doing something wrong but I have no idea.
What's the best way to call a long method in order to not block the UI?
EDIT
I changed my code to isolate the time-consuming part.
reportViewer.SetPageSettings(reportConfiguration.PageSettings);
Using a backgroundWorker on this part did it. Thank you for your help.
@LuisQuijada: That worked, post an answer so I can accept it.
using System.Threading;
new Thread(() =>
{
Thread.CurrentThread.IsBackground = true;
/* run your code here */
Console.WriteLine("Hello, world");
}).Start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With