When loading big data collections or switching between views that contain a lot of data, there is often a big timespan where the user is not sure if the application has crashed or if it is doing something.
So I wanted to draw a semi transparent overlaying layer over the window and create an animation that indicates that the application is doing some work.
Sounds easy... In reality it's something that's almost impossible!
In wpf the UI thread is not the same as the main application thread. But still they are linked to each other so that the UI thread gets blocked when the main thread is working hard. With this restriction there can't be any semi transparent layer and especialy no animation that gets shown or executed while the main thread is working.
When I was about to give up I stumbled upon a grea thread by Dwayne Need describing how single elements in wpf can be run in a separate thread. This means some complicated threading and trying to get the data binding and the resizing of the controls syncronized between the different threads, but in the end I managed to get it all worked out.
Now I am able to display an animation while the main tread is doing some hard work trying to accomplish whatever tasks I let it do.
No comments:
Post a Comment