동기/비동기 모두 사용 가능.
private void _InsertMessage(string s)
{
string strDatetime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
if (RichTextBox.InvokeRequired)
{
RichTextBox.BeginInvoke(new Action(() => RichTextBox.AppendText("[ " + strDatetime + "] : ")));
RichTextBox.BeginInvoke(new Action(() => RichTextBox.AppendText(s + System.Environment.NewLine)));
RichTextBox.BeginInvoke(new Action(() => RichTextBox.ScrollToCaret()));
}
else
{
RichTextBox.AppendText("[ " + strDatetime + "] : ");
RichTextBox.AppendText(s + System.Environment.NewLine);
RichTextBox.ScrollToCaret();
}
}
댓글 없음:
댓글 쓰기