Please, read my comment first.
Have a look here:
http://www.experts-exchange.com/Programming/Languages/.NET/Q_23786595.html[
^]
In case you're not able to view the solution, please see:
pb.Style = ProgressBarStyle.Marquee;
pb.MarqueeAnimationSpeed = 30;
private BackgroundWorker worker = null;
worker = new BackgroundWorker();
worker.DoWork +=new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerAsync();
void worker_DoWork(object sender, DoWorkEventArgs e)
{
BuildTree();
}
The concept is to use BackgroudWorker.
http://www.c-sharpcorner.com/UploadFile/LivMic/BGWorker07032007000515AM/BGWorker.aspx[
^]
If you would like to show form with progressbarr on the center of parent form, use proper
StartPosition[
^] or Location.
How to: Set the Screen Location of Windows Forms[
^]