I am porting over an Outlook add-in from Visual Basic 6 to C# 2.0 (Visual Studio 2008). I have two forms a "main" and "progress" in which the main has all the logic and controls while progress just contains a progressbar control.
The application makes several calls to various databases on startup so I would like to display an "activity/indeterminate" progress indicator while the main form is processing. My question is how can I display this progressbar? Using Google I have seen mention of threads and delegates but I have not made many successful inroads in this arena.
The code below does not work because the Progressbar does indeed show but never repaints. Or depending upon order the progressbar form might show up but not until after the main form load is complete thus defeating the purpose.
Ideally I would like three separate threads main (default), BuildMyTree (populates treeview control), and Progress (updates progressbar). But being unfamiliar with the techniques and running to controls that are not thread-safe I am uncertain of how to proceed.
Progress pb = new Progress(); //ProgressBar form
BuildMyTree(); //Main form gathers data and fills tree