In short, I use C # for scientific computation, and I wrote a method that has a while loop that can execute with a number of steps given by the user ... Actually this method can take too long to execute (for example, more than 5 hours ) When this takes a long time, I can, for example, stop the method by pressing the Esc key .
As I read something about breaking while , it is as simple as a Boolean flag or something like that. So I thought something like this:
public Double? Run(int n) { int i = 0; while ((i < n) && ()) {
Well, thatโs what Iโm still thinking about ... So, please, could you give some useful ideas in this area? How can I wait for user input (I was thinking about Events , but I'm not sure how to implement it here, and I think this will make the code even slower if I have to listen to the key every time the code step goes to ...
Well, any ideas or comments?
Refresh . I think I would better describe the problem. All the solutions you gave me can solve this problem that I proposed, but I think I was not completely sure of my real problem. I do not know if I should ask another question or continue with this ...
source share