Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 加工用螺纹块_C#_.net_Wpf_Windows_Multithreading - Fatal编程技术网

C# 加工用螺纹块

C# 加工用螺纹块,c#,.net,wpf,windows,multithreading,C#,.net,Wpf,Windows,Multithreading,我正在编写一个C#wpf应用程序,我需要阻止处理以等待事件。 如果我使用Thread.Sleep(),事件永远不会被触发,UI也会挂起,所以我不知道还能做什么 switch (process.Action) { case 1: this.Goto(process.VarValue); break; case 2:

我正在编写一个C#wpf应用程序,我需要阻止处理以等待事件。 如果我使用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;
            }
和“extract”案例一样,它获取信息并将事件发送给服务,服务打开另一个WPF窗口,弹出窗口,请求用户输入

UI显示,但submit按钮挂起,然后应用程序挂起,我使用unity和eventaggregator,也是wpf的Magellan,因此项目变得越来越复杂

我正在尝试一种更简单的方法,让线程等待用户输入

请告知

  • 线程启动=>开关
  • on extract case=>将事件发送到弹出式服务打开(wpf窗口,用于用户输入)
  • 我正在使用thread.sleep(1000),直到服务发送响应事件
  • 但应用程序在使用thread.sleep(包括弹出窗口)时挂起
  • 我想等待主线程上的用户输入

  • 使用
    Window.ShowDialog
    打开弹出窗口。仅当pop再次关闭后,Showdialog才会返回。看见不需要复杂的线程scanario。

    不确定我是否了解在哪个线程中运行的是什么?你能详细说明一下吗?确保你没有阻塞UI线程。