线程中show 窗口的问题
while (ServerRun)
{
try
{
using (HttpWebResponse response = HttpWeb.HttpWebResponseUtility.CreatePostHttpResponse(url, para2, cookie))
{
if (response != null && response.StatusCode == HttpStatusCode.OK)
{
string result = HttpWeb.HttpWebResponseUtility.GetData(response, Encoding.UTF8);
AlertLib.AlertForm f = new AlertLib.AlertForm();
f.Show(result , "提示", AlertLib.AlertForm.ShowWay.Fade, 300, 200, 200, 3000, 500);
}
}
}
catch (System.Exception ex)
{
}
Thread.Sleep(10000);
Application.DoEvents();
//GC.Collect();
}
/// <summary>
/// 替代使用InvokeRequired
/// </summary>
static class ControlExtensions
{
public delegate void ActionShow();
/// <summary>
/// 从worker thread 调用UI Thread的控件的方法
/// </summary>
/// <param name="control"></param>
/// <param name="code"></param>
static public void UIThread(this Control control, ActionShow code)
{
if (control.InvokeRequired)
{
control.BeginInvoke(code);
return;
}
code.Invoke();
}
}