Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash in cmd.InvokeOnce()....where is my error? RESOLVED #31

Open
allucche opened this issue Mar 31, 2020 · 1 comment
Open

crash in cmd.InvokeOnce()....where is my error? RESOLVED #31

allucche opened this issue Mar 31, 2020 · 1 comment

Comments

@allucche
Copy link

In My class i define:

private IXPlaneApi m_api = null;

In the constructor:
public xPlaneSerialCom(IXPlaneApi api)
{
m_api = api;
......
}

When I send cmnd to xPlane in this function the system crashes:

private void SendCMND(string cmndString,int actionInt)
{
IXPCommand cmd = null;
cmd = m_api.Commands.GetCommand(cmndString);

    switch (actionInt)
     {
            case BEGIN:
                cmd.Begin();
                break;
            case END:
                cmd.End();
                break;
            case ONCE:
                cmd.InvokeOnce();
                break;
      }

}

Where is my error?
Thank you very much!
Alessio

@allucche
Copy link
Author

allucche commented Apr 3, 2020

I solved:
#23: X-Plane must only be called from the thread that it creates the Plugin on. Trying to read datarefs or make other calls back into X-Plane from other threads might crash the sim and might give you invalid data values, just as you're seeing.
To do a timer, you have to let X-Plane do it for you. In XPNet you can do that with IXPlaneApi.Processing.RegisterFlightLoopHook().

Thanks

@allucche allucche changed the title crash in cmd.InvokeOnce()....where is my error? crash in cmd.InvokeOnce()....where is my error? RESOLVED Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant