/// <summary> /// Writes the status to the statusbox. /// </summary> /// <param name="Update">The update.</param> /// <param name="writecolor">The color to use for writing text into the text box.</param> public void WriteStatus(string Update, Color writecolor) { // Check if thread-safe if (statusbox.InvokeRequired) { Debug.WriteLine("InvokeRequired..."); WriteStatusCallback wsc = new WriteStatusCallback(WriteStatus); this.Invoke(wsc, new object[] { Update, writecolor }); return; } // Small function for writing text to the statusbox... int startlen = statusbox.TextLength; if (statusbox.Text == "") statusbox.Text = Update; else statusbox.AppendText("\r\n" + Update); int endlen = statusbox.TextLength; // Set the color statusbox.Select(startlen, endlen - startlen); statusbox.SelectionColor = writecolor; // Scroll to end of text box. statusbox.SelectionStart = statusbox.TextLength; statusbox.SelectionLength = 0; statusbox.ScrollToCaret(); // Also write to console Console.WriteLine(Update); }