I have a WPF application with fields populated by 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 the SSRS message. Everything works fine, but it takes a lot of time, mainly because of the report, which means my user interface is becoming unresponsive. I tried several ways to start a new thread / task, but they all block the UI thread. I'm probably doing something wrong, but I have no idea.
What is the best way to call a long method so as not to block the user interface?
@Kyle Here is the last working (but blocking) method I tried
var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { }) .ContinueWith(r => DoTimeSheetReport(), scheduler);
EDIT
I modified my code to isolate the laborious part.
reportViewer.SetPageSettings(reportConfiguration.PageSettings);
Using backgroundWorker in this part did it. Thank you for your help.
@LuisQuijada: It worked, send an answer so that I can accept it.
source share