I ran into a big problem: in my WPF application, MainWindow contains a border with loading animations (storyboard). By default, it crashed. Sometimes I make it visible and crash when I load a lot of data or when I load a new XAML screen.
First of all, I did not use Threading at all and the animation, where both freeze and appear with the latter.
Then I started using Threading as follows:
Messenger.StartAnimation(); var task = Task.Factory.StartNew(() => { Thread.Sleep(150); }).ContinueWith((a) => { // HERE Screen moving + large amount of data loaded with Entity Framework Thread.Sleep(200); Messenger.StopAnimation(); }, CancellationToken.None, TaskContinuationOptions.NotOnFaulted, threadUIContext);
This time, the animation worked for 1 second, and then it just hung until all the data and the new displayed screen were loaded. A This is how the main thread blocks ALL threads.
I tried adding a timer to delay my Messenger.StopAnimation() up to 3 seconds later. Even this freezes my animation for 1 second, when everything changes and loads onto my new screen, and then my animation lasts for 3 seconds.
I tried Dispatcher , BackgroundWorker and ran the same issue as with the previous code.
I tried to include the animation in a popup and even in a new window that was transparent. Nothing to do, it always ends with freezing for 1 second until it stops ...
For information, I use an ObservableCollection (I tried with List, the same problem), and I load different screens inside the ContentControl in my MainWindow .
I watched the Techdays, Fast, and Furious videos, and I really wanted to get smooth animation like the video, but the freeze seems impossible to remove.