title: Thread, progressbar howto
body: <p>I'm using <code>XslCompiledTransform</code> to transform XML file to HTML.
  XML file is not so short, so transformation is waste a lot of time.</p>
  
  <p>My code:</p>
  
  <pre><code> xslTransform.Transform(fi.FullName, TMP_TRANSFORMED_XML_PATH);
   webBrowser1.Navigate(TMP_TRANSFORMED_XML_PATH);
  </code></pre>
  
  <p>So I want to use progress-bar or (better) progress icon (dialog?) which is not bound to a form.</p>
  
  <p>The problem is that I have two forms. 
  The 1st one has a list of items and a button, when item selected and button is pressed, 2nd form is shown (not modal), XML file transforms and it's shown in WebBrowser control. </p>
  
  <p>In 2nd form constructor I call <code>XslCompiledTransform.Load</code>, initialize controls and then call <code>XslCompiledTransform.Transform()</code>.</p>
  
  <p>In a second form I also have buttons to navigate between 1st form list items. So when I press '>' then the next element from 1st form is selected, and 2nd form's elements are reloaded - e.g. some text changed and XslCompiledTransform.Transform() is called again for a new XML file.</p>
  
  <p><strong>So, how to organize progress bar while 2nd form is loading each time?</strong></p>
  
  <p>From 1st Form :</p>
  
  <pre><code>private void OpenSecondForm()
  {
      if (formTwo == null)
      {
              formTwo = new FormTwo(this, culture, params);
              formTwo .Show();
      }
      else
      {
              if (formTwo .IsDisposed)
              {
                  formTwo = new FormTwo(this, culture, params);
                  formTwo .Show();
              }
              else
              {
                  formTwo .Reinitialaze(culture, invoice);
              }
              formTwo .BringToFront();
      }
  
  }
  
  public void SelectRow(int moveTo)
  {
      try
      {
        /*navigate on list here */
    /* ... */
  
  OpenSecondForm();
      }
      catch (Exception e)
      { MessageBox.Show(e.Message, "ERROR"); }
  }
  </code></pre>
  
  <p>2nd form:</p>
  
  <pre><code>public FormTwo(Form parent, CultureInfo cultr, string params)
  {
      culture = cultr;
  
      parentForm = parent;
      rm = new ResourceManager("MyProject.Resource", typeof(FormOne).Assembly);
      InitializeComponent();
  
      xslTransform = new XslCompiledTransform();
      xslTransform.Load(XSL_TRANSFORM_SCHEMA_NAME);
  
      ReInitialazeAll();
  
  }
  
  internal void Reinitialaze(CultureInfo cultr, string params)
  {
      culture = cultr;
  
      ReInitialazeAll();
  }
  
  private void ReInitialazeAll()
  {
      SelectDatabaseData();
  
      InitCaptions();
      InitForms();
  
  }
  
  private void InitForms()
  {
      EnableDisableButtons();
      webBrowser1.DocumentText = "&lt;HTML&gt;&lt;BODY&gt;&lt;/BODY&gt;&lt;/HTML&gt;";
  
      FillXmlData();
  }
  
  private void FillXmlData()
  {
      xslTransform.Transform(fi.FullName, TMP_TRANSFORMED_XML_PATH);
      webBrowser1.Navigate(TMP_TRANSFORMED_XML_PATH);
  }
  </code></pre>
  
  <p>I've tried to create a thread to execute these FillXmlData. But my forms is still not accessible while xml is transforming.</p>