Stop the method and wait for user input

My program is written in C # and has a graphical interface in WPF. When you click one button, the method starts StopAndGo().

The problem is that I want this method to stop at certain points, wait for user input, and continue.

I assume that this can be done using multithreading, but since I have never studied this topic, I want to be sure that it can be done and whether it will be difficult to do before studying it.

Can you give me some recommendations on what to do?

Thank.

+3
source share
5 answers

, , , - . , , , , . , .

+3

ManualResetEvent. , StopAndGo();

 this.manualResetEvent.WaitOne(TimeSpan.Infinite,false);

,

this.manualResetEvent.Set();

, stopANdgo

0

, , , .

, , , ManualResetEvent.

0

, - .

DialogBox dialogBox = new DialogBox();

// Show window modally 
// NOTE: Returns only when window is closed
Nullable<bool> dialogResult = dialogBox.ShowDialog();

https://msdn.microsoft.com/en-us/library/system.windows.window.showdialog(v=vs.110).aspx

0

Source: https://habr.com/ru/post/1775267/


All Articles