Queuing functions so they fire synchronously

50 Views Asked by At

I have an application which controls some stepper motors using a propriety DLL. I am finding I occasionally get errors where it seems as though the functions I am using to communicate with the controllers are firing too close together and not allowing time for the controller to respond.

private void CommandZ(string command)
{
    DMX_UMD_API.Flush(hUSBDevice_Z);

    string tmpString = "";
    bool status;
    status = DMX_UMD_API.performaxSendAndGetReply_Z(hUSBDevice_Z, command, out tmpString);
}

public string loopCommands_Z(string command)
{
    DMX_UMD_API.Flush(hUSBDevice_Z);
    string tmpString = "";
    bool status;
    status = DMX_UMD_API.performaxSendAndGetReply_Z(hUSBDevice_Z, command, out tmpString);
    if (status)
    {
        return tmpString;
    }
    else
    {
        return "";
    }
}

How can I queue the functions so they occur synchronously?

0

There are 0 best solutions below