Exemple #1
0
            public void FlushCache()
            {
                lock (m_builders)
                {
                    int caretPosition     = 0;
                    int currentTextLength = 0;

                    if (!m_consoleForm.InvokeRequired)
                    {
                        caretPosition     = m_consoleForm.CaretPosition;
                        currentTextLength = m_consoleForm.TextLength;
                    }

                    bool written = false;
                    for (int i = 0; i < m_builders.Length; i++)
                    {
                        string text = m_builders[i].ToString();
                        if (string.IsNullOrEmpty(text))
                        {
                            continue;
                        }

                        written = true;

                        m_builders[i].Clear();

                        if (m_consoleForm.InvokeRequired)
                        {
                            m_consoleForm.Invoke((MethodInvoker)(() => m_consoleForm.AppendText(text, COLORS[i])));
                        }
                        else
                        {
                            m_consoleForm.AppendText(text, COLORS[i]);
                        }
                    }

                    if (!m_consoleForm.InvokeRequired && written && caretPosition == currentTextLength)
                    {
                        m_consoleForm.ScrollToCaret();
                    }
                }
            }
            public void FlushCache()
            {
                lock (m_builders)
                {
                    for (int i = 0; i < m_builders.Length; i++)
                    {
                        string text = m_builders[i].ToString();
                        m_builders[i].Clear();

                        if (m_consoleForm.InvokeRequired)
                        {
                            m_consoleForm.Invoke((MethodInvoker)(() => m_consoleForm.AppendText(text, COLORS[i])));
                        }
                        else
                        {
                            m_consoleForm.AppendText(text, COLORS[i]);
                        }
                    }
                }
            }