I want to start the simulation from code.
I tried with the following code, but the simulation doesn’t start (the time stays 0:00:00). When I hover over the play button, the text is changed from “play” to “pause”, so the code does something.
var runTime = IoC.Get<ISimulationSettingViewModel>().SimulationRunTime;
Can someone help me how to start the simulation from code?
Thanks in advance,
I guess the simulation doesn’t run because you didn’t set the runTime value. Try the following. Note the last line of code is used if you do not want to set the duration of the simulation run.
public void RunSimulation()
// Default simulation run time is 9999 years
var simulationRunTime = 315328464000; // 60*60*24*365*9999 (9999 years in second)
Thanks for your response.
This code has the same behaviour.
Is it possible that it depends from the thread your calling the code on? In my case it is a seperate thread, maybe this causes the problem.
None of the VC .NET API is thread-safe. You should always use it from the main application thread only.
You can run the code in the UI thread by utilizing Caliburn Micro:
//your code here