FengChendian / serial_port_win32

A flutter SerialPort library using win32 API.
BSD 3-Clause "New" or "Revised" License
31 stars 9 forks source link

port.readBytesOnListen make UI hang/freeze a few millisecond when data come #11

Closed indrawow closed 2 years ago

indrawow commented 2 years ago

Using this code, _port.readBytesOnListen(255, (Uint8List value) { debugPrint(value.toString()); }); then, _port.writeBytesFromUint8List(uint8Data);

UI freeze a few millisecond, is there something i missed?

FengChendian commented 2 years ago

I use a stream to read with duration. I think I should fix the UI freezed problem.

But _read is still a sync processing due to Windows 32API. Maybe you can use async or compute to solve this problem.

FengChendian commented 2 years ago

Refer to PR #16 , maybe due to WaitForSingleObjec blocking.

If there is still problom about UI freeze, please tell me