Reputation: 1207
I'm coding a C# wpf app and I need to block processing in order to wait for an event. If I use Thread.Sleep() the event is never triggered, the UI also hangs, so I don't know what else to do.
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.
The UI shows, but submit button hangs, and then the application hangs, i m using unity, and eventaggregator, also Magellan for wpf, so the project is getting more and more complex.
I am trying for a simpler method for the thread to wait, for the user input.
Please advise.
Upvotes: 0
Views: 266
Reputation: 14387
Use Window.ShowDialog
to open your pop up window. Showdialog will return only after the pop has been closed again. See here. No need for complex threading scanario's.
Upvotes: 1