I implemented the algorithm in C # and I want to make a gui for it, in my gui I want to put a button that with any click of gui shows a step forward in the algorithm, so I think I need to add something to Pause? in my code, which can resume with any click of the mouse. how should i do this? or is there any other suggestion for implementing this idea?
It seems that you really need to turn your algorithm into a state machine - instead of actively “pausing” it, you would actively “promoting” it.
... , , yield return , .
yield return
, . GetEnumerator , MoveNext() , ( Current ). , .
GetEnumerator
MoveNext()
Current
myWaitHandle.WaitOne()
myWaitHandle.Set()
, , .
, "" . :
interface ISteppedAlgorithm { bool NextStep(); //returns if the algorithm is finished IStepResult LastStepResult {get;} }
, . NextStep(). false, ( , ). LastStepResults display.h
, "", / .
http://www.differentpla.net/content/2005/02/implementing-wizard-c
.
, .
, , , var:
LongRunningMethod1(); while(continue1 == true) { Thread.Sleep(50); } LongRunningMethod2() while(continue2 == true) { Thread.Sleep(50); }
continue1 2 true , .
If you simply “observe” the state of the algorithm as it develops, why not add some events (perhaps only one at the end) and allow the event handler to store an array of states. The user interface can simply skip forward / backward when and when necessary.
Source: https://habr.com/ru/post/1751590/More articles:PHP cURL не хранит файл cookie сеанса... Как это исправить? - postHow to set an attribute of an XML element using linq in xml in C # - c #How can I use PHP to get the nth element in a JSON object? - jsonHow to remove character symbol ^ M - dosBest practices for javascript / jquery - jqueryHow to configure IIS when debugging in Visual Studio 2010? - c #Chapter The first design patterns: decorator behavior is perplexing - javaVS2010 F # Smart Tag for adding open import ads - visual-studioShould I use F # to analyze charts? - graphHow to configure Qt to work with Visual Studio 2010? - c ++All Articles