this might be a very general question - but I'm quite new to C#. Can you please explain this to me or give me a good link to an example or explanation.
I want to design a C# Winform application. The application has a main form, which collects user input when needed. Together with the UI a complex an long running calculation algorithm is developed. Start of calculation is triggered from a button on the main form. (CaculateClass.Start())
Question 1: At some point in time deep in the method call stack of the CaculateClass the CaculateClass detects that it needs further input from the user to continue the calculation.
In ancient C++ console application times one would have done something like this: cout << "Ask question"; cin >> answer;
How is this done in C# with winforms, to pass control to the UI from somewhere deep in the call stack, get input and return to the place where the calculation was interupted? Or has the CaculateClass to be designed somehow completely different?
Question 2 To avoid freezing of the UI a lot of articles recommend to put such long running calculations into another thread - e.g. by using BackgroundWorker()
If I let the CaculateClass.Start() be calculated by a BackgroundWorker -> How does the collecting user input work then?
Thanks for any help, CS