WPF使用 Task.Delay 产生延迟不成功

wangzhihongji wangzhihongji 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
///////////////以下为楼主某个事件响应函数的代码

private void Button_Click_4(object sender, RoutedEventArgs e)
{
//turning
int isornotsuccess = 0;
Task.Delay(50000);

ImformationText.Text = null;
ImformationText.Text += String.Format("\r\nwe have released if you input the wave-number,or release 100-band if you not. . . .\r\n");
ThreadPool.QueueUserWorkItem((object o) =>//这后面一长串是一个语句,一个线程
{
myout.Result = " calling the function....";
Task.Delay(200000);
int bandnum = 0;
if (Convert.ToInt32(myout.Waveband) < 128 && Convert.ToInt32(myout.Waveband)>= 0)
{
bandnum=Convert.ToInt32(myout.Waveband);
}
else
{
bandnum = 100;
}
isornotsuccess = MyTurnImageDll.MyTurnImage(exportpath, importpath, bandnum);

if (isornotsuccess == 1)
{
myout.Result = "turnning success";
}
});

}

////////////////问题
调试的时候,完全没有延迟的效果,两个Delay都没有发挥作用。。。怎么回事?
...全文
评论 4
收藏 已收藏
分享
返回顶部
wangzhihongji
C# 111,128 成员 642,537 内容