start the simulation from code

Forum Forums Visual Components 4.1 .NET Addon Programming start the simulation from code

This topic contains 4 replies, has 4 voices, and was last updated by Avatar jouha 2 weeks, 4 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19832
    Avatar
    mschamp
    Participant

    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.

    Can someone help me how to start the simulation from code?
    Thanks in advance,
    0
    #19999
    Jay
    Jay
    Moderator

    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.

     

    0
    #20176
    Avatar
    mschamp
    Participant

    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.

    0
    #20192
    TSy
    TSy
    Participant

    None of the VC .NET API is thread-safe. You should always use it from the main application thread only.

    0
    #20196
    Avatar
    jouha
    Moderator

    You can run the code in the UI thread by utilizing Caliburn Micro:

     

     

    0
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.