My C# application receives about 80 bytes per second from a bluetooth sensor. While receiving those bytes I occasionally get a System.AccessViolationException in wcl.dll.
My wclClient.OnData handler looks like this:
private void OnDataReceived(object sender, wcl.wclDataEventArgs e)
{
lock (mRxBytesLock)
{
mRxBytes.AddRange(e.Data);
}
}
While receiving data I frequently scan for new devices using a wclBluetoothDiscovery and send data every few seconds:
private void SendTgm(byte[] tgm)
{
try
{
lock (mSendLock)
{
if (IsConnected)
{
wcl.wclErrors.wclShowError(mClient.Write(tgm, (uint)tgm.Length));
if (TgmSent != null)
TgmSent(new List<byte>(tgm));
}
}
}
catch
{
Disconnect();
}
}
Any idea on what could cause the access violation inside wcl.dll?