这是我在蓝牙打印机上打印数据的代码
using (BluetoothSocket bluetoothSocket = device?.CreateRfcommSocketToServiceRecord(serialUUID))
{
try
{
if (!bluetoothSocket.IsConnected)
{
bluetoothSocket?.Connect();
}
string sss = " Sample Test Line \nSample Test Line";
byte[] buffer = Encoding.UTF8.GetBytes(sss);
bluetoothSocket?.OutputStream.Write(buffer, 0, buffer.Length);
bluetoothSocket.Close();
}
catch (System.Exception e)
{
}
}
当我在调试模式下测试此代码时,仅当我在任意行上设置断点时才打印。但是删除断点后将不打印任何内容。
如何解决这个问题?