Home > OS >  WPF not sequential operating with control changes and excel export
WPF not sequential operating with control changes and excel export

Time:03-09

I'm currently making an export app that would run a query in the db and store them in excel.

So my code will change the text of status and collapsed the visibility of the button when pressed.

Here is my code block:

        statusTextBlock.Text = "Export is running...";
        ExportDryRunBtn.Visibility = Visibility.Collapsed;
        GPDatabase.ExportDryRunItemsToExcel(progressBar);
        ExportDryRunBtn.Visibility = Visibility.Visible;
        statusTextBlock.Text = "";

My issue is that when I press export, the status won't change and the visibility will not collapsed. The application will not be responsive until it finishes the export then the other control changes will show up. I have a similar application that I worked on Windows Form with the same code structure and it works as intended.

Any reason why I can't do the same thing with WPF?

CodePudding user response:

Your export function is probably taking a long time to complete, therefore you need to make it async and await it so you don't block the UI thread in WPF.

  • Related