private void button1_Click(object sender, EventArgs e)
{
Thread threadstart = new Thread(new ThreadStart(Mystart));
threadstart.IsBackground = true;
threadstart.Start();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (richTextBox1.Text.Length == 4)
{
detailCollectedEvent.Set();
}
}
AutoResetEvent detailCollectedEvent = new AutoResetEvent(false);
private void Mystart()
{
Con();
detailCollectedEvent.WaitOne();
SendPost(richTextBox1.Text);
}为啥我在richTextBox中输入完文本,程序不继续执行.求指点
{
Thread threadstart = new Thread(new ThreadStart(Mystart));
threadstart.IsBackground = true;
threadstart.Start();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (richTextBox1.Text.Length == 4)
{
detailCollectedEvent.Set();
}
}
AutoResetEvent detailCollectedEvent = new AutoResetEvent(false);
private void Mystart()
{
Con();
detailCollectedEvent.WaitOne();
SendPost(richTextBox1.Text);
}为啥我在richTextBox中输入完文本,程序不继续执行.求指点
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Thread threadstart = new Thread(new ThreadStart(Mystart));
threadstart.IsBackground = true;
threadstart.Start();
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (richTextBox1.Text.Length == 4)
{
detailCollectedEvent.Set();
}
}
AutoResetEvent detailCollectedEvent = new AutoResetEvent(false);
private void Mystart()
{
Step1();
detailCollectedEvent.WaitOne();
Step2();
} private void Step2()
{
Invoke(new Action(() => this.Text = "2"));
} private void Step1()
{
Invoke(new Action(() => this.Text = "1"));
}
}
}看看问题是不是出在con sendpost里面。