© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
18 replies
frknztrk

❔ C Task this.Dispatcher.Invoke lock problem

 private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            letspaly = Task.Run(() => loadItem());

            letspaly.Wait();
            Debug.WriteLine("End ?");
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            letspaly = Task.Run(() => loadItem());

            letspaly.Wait();
            Debug.WriteLine("End ?");
        }


 public void loadItem()
        {
            using (var entitydb = new AyetContext())
            {

               this.Dispatcher.Invoke(() =>
                {
                    listBorder.Visibility = Visibility.Visible;
                    stackBorder.Visibility = Visibility.Collapsed;
                });

            }

}
 public void loadItem()
        {
            using (var entitydb = new AyetContext())
            {

               this.Dispatcher.Invoke(() =>
                {
                    listBorder.Visibility = Visibility.Visible;
                    stackBorder.Visibility = Visibility.Collapsed;
                });

            }

}



I will get the data every time the page is loaded with the task, but the program hangs with invoke while the task is waiting
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Ookii.Dialogs.Wpf ProgressDialog BackgroundWorker Dispatcher.Invoke not working.
C#CC# / help
3y ago
✅ Problem with task
C#CC# / help
2y ago