public void writeData()
{
UInt32 txBuf = 0, rxBuf = 0, status = 0;
while (!done)
{
//Check if all the data has been written yet.
FT_GetStatus(handle, ref rxBuf, ref txBuf, ref status);
while (txBuf != 0)
{
//Not ready yet, wait for a bit
Thread.Sleep(2);
//Check the transmit buffer again
FT_GetStatus(handle, ref rxBuf, ref txBuf, ref status);
}
//Keep buffer from channging while being copied to the output.
lock (buffer)
{
//Create a break signal in the output before the DMX data.
FT_SetBreakOn(handle);
FT_SetBreakOff(handle);
//Send the next frame to the driver
bytesWritten = write(handle, buffer, buffer.Length);
}
//Goto sleep while data is transmitting
Thread.Sleep(25);
}
//Free any used memory from write()
Marshal.FreeHGlobal(transmitPtr);
}