Question

I am making a sartup animation screen in my wpf app . And i want to do some work during that animation . How to do this ? i want to do some sticky stuff in that time ? so that my app run faster after that animation .

how can i do this ?

Was it helpful?

Solution

If you are talking about non-UI related "sticky stuff", like loading some data, you can off load the heavy work into a background thread, for example:

// Start playing loading animation (you can use visual state like Gusdor suggested)
Task.Factory.StartNew(()=>
{
    // Do heavy work here.
}.ContinueWith(task => 
{
    // Stop loading animation here
}, TaskScheduler.FromCurrentSynchronizationContext());

If your heavy work involves UI activities, I recommend doing it right before stopping the loading animation in the ContinueWith block. Unfortunately, UI activities can only be done on the UI thread, so whatever you are doing in the ContinueWith block will cause some degree of UI pauses, regardless whether they are observable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top