弹出窗口假死怎么办? 当你调用 ShowAlarm 的时候,应该确保在UI主线程调用它。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 dlg.TopMost = true; dlg.Show();-> dlg.Show(this); 实测,不行,线程间操作无效: 从不是创建控件“MainForm”的线程访问它。这里是不是应该用委托? dlg 是个什么东西? private void button1_Click(object sender, EventArgs e) { Thread th = new Thread(ShowMessage); th.IsBackground = true; th.Start(); } //非UI线程的操作方法 void ShowMessage() { if (this.InvokeRequired) { Action<string> Show = (o) => { //非UI线程操作UI控件时的方法写到这里 //... }; this.Invoke(Show, string.Empty); } } 大家推荐一个免费的net混淆工具吧 c# 在word中指定位置插入图表 C# 桌面程序怎么模拟点击网页错误警告窗的button? 使用.NET读取远程网页的源代码? 请问能否通过编写代码关闭硬盘 一个数的开根算法是怎么样的?比如4的开2次方根是2,4的开3次方根是? 关于序列化的问题 怎么在c#中实现删除sql server中某个表中的某列?--谢谢 MSMQ如何异步一次性读取所有消息 给大家分享一个网站,全球第二好用JS美化http://istool.cn 好用请收藏,谢谢 C#界面设计问题 C# winform 窗体设置Owner后showdialog报错
dlg.Show();
->
dlg.Show(this);
线程间操作无效: 从不是创建控件“MainForm”的线程访问它。这里是不是应该用委托?
private void button1_Click(object sender, EventArgs e)
{
Thread th = new Thread(ShowMessage);
th.IsBackground = true;
th.Start();
} //非UI线程的操作方法
void ShowMessage()
{
if (this.InvokeRequired)
{
Action<string> Show = (o) =>
{
//非UI线程操作UI控件时的方法写到这里
//... };
this.Invoke(Show, string.Empty);
}
}