//uses invoke to update ui code from a different thread
 public void UpdateInfo(string code)
 {
     try
     {
         if (!InvokeRequired)
         {
             TB_Info.Text               = code;
             TB_Info.SelectionColor     = Color.Yellow;
             TB_Info.SelectionBackColor = Color.White;
             TB_Info.Refresh();
         }
         else
         {
             Invoke(new Action <string>(UpdateInfo), code);
         }
     }
     catch { }
 }
        //uses invoke to update highlighted lines of code from a different thread
        public void UpdateBox(int line, int line2)
        {
            try
            {
                if (!InvokeRequired)
                {
                    //need to scroll?
                    bool scroll = false;
                    //character locations of start and end of highlight
                    var startIndex = TB_Info.GetFirstCharIndexFromLine(line - 1);
                    var endIndex   = TB_Info.GetFirstCharIndexFromLine(line2);

                    //if the highlighted lines are above previously highlighted ("off screen") then scroll
                    if (TB_Info.SelectionStart > startIndex)
                    {
                        scroll = true;
                    }

                    //highlight
                    TB_Info.Select(startIndex, (endIndex - 1) - startIndex);
                    //refresh ui element
                    TB_Info.Refresh();
                    //give element focus
                    TB_Info.Focus();

                    //if needed scroll to the right location
                    if (scroll)
                    {
                        TB_Info.ScrollToCaret();
                    }
                }
                else
                {
                    Invoke(new Action <int, int>(UpdateBox), line, line2);
                }
            }
            catch { }
        }