It’s a Windows Form Application
And kind of code:
public bool Simulation(string param1, bool param2)
{
//code1
do
{
bool success = reader.Launch();
//code2
} while (!success);
}
Launch() method takes a long time but I have to wait in this place (“code2“) at the same time having access to the GUI. Now Launch() is blocking this access.
How can I do this?
It’s a bit hard to understand exactly what you need, but it sounds like you want to run your entire Simulation method on a separate thread from your UI thread. If that is the case, you can just do something like this:
Note that result would be populated from a second thread… it’s not clear from the question if you need to access result, or from which thread. If you can clarify that, I can give more concrete guidance on how/where to check result.