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

WPF UI thread problem

$
0
0

 This my code block.

private async void BtnApplyall_Click(object sender, RoutedEventArgs e)
        {     
            try
            {
                ucLoading.Visibility = Visibility.Visible;
                await Task.Run(() => ApplyScenarios());
            }
            catch (Exception ex)
            {
               throw;
            }          
        }

        public Task ApplyScenarios()
        {
            try
            {
                Dispatcher.Invoke(() =>
                {                    
                    ApplyAllScenarios(ucScenarioContainer.Children);
                    ucLoading.Visibility = Visibility.Hidden;
                });             
            }
            catch (Exception ex)
            {
               throw;
            }
            return Task.CompletedTask;
        }

My problem is I clicked BtnApplyAll button and then my UI locked until process finished. And My progressbar not turn because of UI locked. I used Task and Dispacther but did not work. How can I handle this problem.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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