title: BackgroundWorker not found
body: <p>I am using the System.componentmodel referance in a windows phone 8.1 to get the BackgroundWorker but each time i put the BackgroundWorker it gives me </p>
  
  <p><strong>Error CS0246  The type or namespace name 'BackgroundWorker' could not be found (are you missing a using directive or an assembly reference?)  HealthBand  C:\Users\husam\Desktop\Projects\HealthBand\HealthBand\ConnectionManager.cs  16</strong></p>
  
  <p>I tried adding the referance but it says it is already added
  and when i put </p>
  
  <pre><code>using System.ComponentModel;
  </code></pre>
  
  <p>it says using directive is unnecessary </p>
  
  <p>here is my code </p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Diagnostics;
  using System.Threading.Tasks;
  using Windows.Networking;
  using Windows.Networking.Sockets;
  using Windows.Storage.Streams;
  using System.ComponentModel;
  
  namespace HealthBand
  {
  /// &lt;summary&gt;
  /// Class to control the bluetooth connection to the Arduino.
  /// &lt;/summary&gt;
  public class ConnectionManager
  {
      private BackgroundWorker dataReadWorker;
      /// &lt;summary&gt;
      /// Socket used to communicate with Arduino.
      /// &lt;/summary&gt;
      private StreamSocket socket;
  
      /// &lt;summary&gt;
      /// DataWriter used to send commands easily.
      /// &lt;/summary&gt;
      private DataWriter dataWriter;
  
      /// &lt;summary&gt;
      /// DataReader used to receive messages easily.
      /// &lt;/summary&gt;
      private DataReader dataReader;
  
      /// &lt;summary&gt;
      /// Thread used to keep reading data from socket.
      /// &lt;/summary&gt;
  
  
      /// &lt;summary&gt;
      /// Delegate used by event handler.
      /// &lt;/summary&gt;
      /// &lt;param name="message"&gt;The message received.&lt;/param&gt;
      public delegate void MessageReceivedHandler(string message);
  
      /// &lt;summary&gt;
      /// Event fired when a new message is received from Arduino.
      /// &lt;/summary&gt;
      public event MessageReceivedHandler MessageReceived;
  
      /// &lt;summary&gt;
      /// Initialize the manager, should be called in OnNavigatedTo of main page.
      /// &lt;/summary&gt;
      public void Initialize()
      {
          socket = new StreamSocket();
          dataReadWorker = new BackgroundWorker();
          dataReadWorker.WorkerSupportsCancellation = true;
          dataReadWorker.DoWork += new DoWorkEventHandler(ReceiveMessages);
      }
  
      /// &lt;summary&gt;
      /// Finalize the connection manager, should be called in OnNavigatedFrom of main page.
      /// &lt;/summary&gt;
      public void Terminate()
      {
          if (socket != null)
          {
              socket.Dispose();
          }
          if (dataReadWorker != null)
          {
              dataReadWorker.CancelAsync();
          }
      }
  
      /// &lt;summary&gt;
      /// Connect to the given host device.
      /// &lt;/summary&gt;
      /// &lt;param name="deviceHostName"&gt;The host device name.&lt;/param&gt;
      public async void Connect(HostName deviceHostName)
      {
          if (socket != null)
          {
              await socket.ConnectAsync(deviceHostName, "1");
              dataReader = new DataReader(socket.InputStream);
              dataReadWorker.RunWorkerAsync();
              dataWriter = new DataWriter(socket.OutputStream);
          }
      }
  
      /// &lt;summary&gt;
      /// Receive messages from the Arduino through bluetooth.
      /// &lt;/summary&gt;
      private async void ReceiveMessages(object sender, DoWorkEventArgs e)
      {
          try
          {
              while (true)
              {
                  // Read first byte (length of the subsequent message, 255 or less). 
                  uint sizeFieldCount = await dataReader.LoadAsync(1);
                  if (sizeFieldCount != 1)
                  {
                      // The underlying socket was closed before we were able to read the whole data. 
                      return;
                  }
  
                  // Read the message. 
                  uint messageLength = dataReader.ReadByte();
                  uint actualMessageLength = await dataReader.LoadAsync(messageLength);
                  if (messageLength != actualMessageLength)
                  {
                      // The underlying socket was closed before we were able to read the whole data. 
                      return;
                  }
                  // Read the message and process it.
                  string message = dataReader.ReadString(actualMessageLength);
                  MessageReceived(message);
              }
          }
          catch (Exception ex)
          {
              Debug.WriteLine(ex.Message);
          }
  
      }
  
      /// &lt;summary&gt;
      /// Send command to the Arduino through bluetooth.
      /// &lt;/summary&gt;
      /// &lt;param name="command"&gt;The sent command.&lt;/param&gt;
      /// &lt;returns&gt;The number of bytes sent&lt;/returns&gt;
      public async Task&lt;uint&gt; SendCommand(string command)
      {
          uint sentCommandSize = 0;
          if (dataWriter != null)
          {
              uint commandSize = dataWriter.MeasureString(command);
              dataWriter.WriteByte((byte)commandSize);
              sentCommandSize = dataWriter.WriteString(command);
              await dataWriter.StoreAsync();
          }
          return sentCommandSize;
      }
  }
  }
  </code></pre>
  
  <p>Please what can I do to fix this error</p>