title: webClient Bot - Multithreading
body: <p>I'm making bot for online game.
  It works, but it is singlethread application.</p>
  
  <p>I want to make it multithread application. 
  I know how background worker works.</p>
  
  <p>To all my tasks I use one WebClient with added Cookie support.</p>
  
  <p>My for example needs to open one page, wait 10 min and do next instruction.
  I also want to be able to stop bot at any time.</p>
  
  <p>Do I have to pass my WebClient object to background worker to work with?
  What is the best way to update controls on my Form?</p>
  
  <p>I have one class that has all the values that I want to show on Main Form.
  Should I fire some event when property changes? If yes, can you give me example?</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is my Special WebClient:</p>
  
  <pre><code>using System;
  using System.Net;
  
  namespace Game_Bot
  {
      class WebClientEx : WebClient
      {
          public CookieContainer CookieContainer { get; private set; }
  
          public WebClientEx()
          {
              CookieContainer = new CookieContainer();
          }
  
          public void ClearCookies()
          {
              CookieContainer = new CookieContainer();
          }
  
          protected override WebRequest GetWebRequest(Uri address)
          {
  
              var request = base.GetWebRequest(address);
              if (request is HttpWebRequest)
              {
                  (request as HttpWebRequest).CookieContainer = CookieContainer;
              }
              return request;
          }
      }
  
  }
  </code></pre>
  
  <p>Is this good way of updating UI? Or is there any beter?</p>
  
  <pre><code>    public void SetStatus(string status)
      {
          if (TransferLeftLabel.Dispatcher.Thread == Thread.CurrentThread)
          {
              TransferLeftLabel.Text = status;
          }
          else
          {
              TransferLeftLabel.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
              (Action)(() =&gt; {  SetStatus(string status); }));
          }
      }
  </code></pre>