none
Showing windows form during addin startup RRS feed

  • Question

  • While starting my Word Addin for the first time, only, some database initialization is to be done, which takes time. I want to show it's progress using a progress bar through a Windows Form. I am even loading the database in the Load function of the windows form. I have called the show function in the StartUp method of Addin. The problem is that during the process the windows form doesn't show up till the end of database loading. How to handle this.

    Dharam Veer Sharma

    Tuesday, October 14, 2014 7:08 AM

Answers

All replies

  • Hello,

    You need to run the long-running task in another thread. Thus, the UI thread will be free to display the results.

    You can update the progress bar value from another thread using the Invoke method of the Control class. Also you may consider using the BackgroundWorker component which has a built-in functionality to report a progress.

    Tuesday, October 14, 2014 7:14 AM
  • Thanks Eugene. Actually I am new to the system. Can you elaborate the solutions and send some links to examples. Thanks in advance.


    Dharam Veer Sharma

    Tuesday, October 14, 2014 9:02 AM
  • See How to: Use a Background Worker .

    The current forum is for VSTO specific questions. I'd recommend asking common programming questions on the Visual C# or Visual Basic forum threads.

    Tuesday, October 14, 2014 11:21 AM
  • Thanks Eugene. BackgroundWorker methods worked. Problem resolved.

    Dharam Veer Sharma

    Tuesday, October 14, 2014 5:22 PM