I have a problem in my WPF app. I have a custom CircularProgressBar
. When I retrieve data from database it takes a few seconds.
I would like to show the CircularProgressBar
in my app while the data is retrieved.
This code runs the CircularProgressBar
:
CircularProgressBar cb = new CircularProgressBar();
stk.Children.Add(cb);
ThreadStart thStart = delegate()
{
ThreadStart inv = delegate()
{
stk.Children.Remove(cb);
};
this.Dispatcher.Invoke(inv, null);
};
Thread myThread = new Thread(thStart);
myThread.Start();
in my custom class (Printer
).
And where I call this window:
Printer p = new Printer();
p.Show();
//Code For retrieve Data from DataBase
p.close();
So this happens : CircularProgressBar
shows for a few seconds and it not running. Where is my bug?