[英]Thread block for processing
I'm coding a C# wpf app and I need to block processing in order to wait for an event.我正在编写 C# wpf 应用程序,我需要阻止处理以等待事件。 If I use Thread.Sleep() the event is never triggered, the UI also hangs, so I don't know what else to do.
如果我使用 Thread.Sleep() 事件永远不会触发,UI 也会挂起,所以我不知道还能做什么。
switch (process.Action)
{
case 1:
this.Goto(process.VarValue);
break;
case 2:
this.Extract(process.VarKey, process.VarValue);
break;
case 3:
this.Validate(new string[] { });
break;
default:
break;
}
Like for "extract" case, it grabs information and sends event to service which opens another WPF window, which pops up, asking user for input.与“提取”案例一样,它获取信息并将事件发送到服务,从而打开另一个 WPF window,它会弹出,要求用户输入。
The UI shows, but submit button hangs, and then the application hangs, im using unity, and eventaggregator, also Magellan for wpf, so the project is getting more and more complex. UI显示,但提交按钮挂起,然后应用程序挂起,我使用unity和eventtaggregator,还有wpf的Magellan,所以项目越来越复杂。
I am trying for a simpler method for the thread to wait, for the user input.我正在尝试一种更简单的方法让线程等待用户输入。
Please advise.请指教。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.