I know I'm missing something stupid, the "StartProcess" Method is making the UI unresponsive and no amount of googling and tutorials has led me to an answer.
Here is my code:
public MainWindow()
{
InitializeComponent();
txtBlock.Text = "Testing";
Initialize();
}
public void Initialize()
{
uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
StartProcess();
}
async void StartProcess()
{
Task<int> result = Task.Factory.StartNew(() =>
{
txtBlock.Text += ("\n starting updater");
while (true)
{
Thread.Sleep(3000);
}
return 0;
}, CancellationToken.None, TaskCreationOptions.LongRunning, uiScheduler);
}
Some background: I'm building an app that has to poll the DB every 5mins and update the UI with a to-do list for the user, hence the while(true) loop. The app has to poll the DB continuously throughout its lifetime.