C# 奇数文本显示#
我在windows窗体中有以下代码:C# 奇数文本显示#,c#,forms,iteration,C#,Forms,Iteration,我在windows窗体中有以下代码: for (int i = 1; (i <= 10); i++) { if ((worker.CancellationPending == true)) { e.Cancel = true; break; } else { try { string me
for (int i = 1; (i <= 10); i++)
{
if ((worker.CancellationPending == true))
{
e.Cancel = true;
break;
}
else
{
try
{
string message = "";
string m = "";
textBox2.Text = "";
int count = 0;
while (TestConnection(client))
{
char tt = ' ';
try
{
tt = Convert.ToChar(sr.Read());
if (count < 4)
{
message = tt.ToString();
m += message;
count += 1;
}
else if (count >= 4)
{
this.Invoke(new BindTextBoxControl(UpdateTextbox), new object[] {m + "\r\n"});
textBox2.Text = m + "\r\n";
m = "";
count = 0;
}
}
catch (OverflowException)
{
m += "";
}
}
}
catch (Exception g)
{
string error = "An error occurred: '{0}'" + g;
}
这些没有什么特别之处。您可以共享
UpdateTextbox
和BindTextBoxControl
的代码吗?还添加了请求的信息。
private void UpdateTextbox(string _Text)
{
textBox1.Text = _Text;
}
delegate void BindTextBoxControl(string text);