c# - .NET Serial Port BeginRead blocking over remote desktop session -


i troubleshooting issue application monitors com port in application hangs when try close it. on own machine closes fine. testing app on terminal server, , have com ports shared via remote desktop. on remote desktop session app hanging infinitely , cannot closed via task manager "end process" either.

the basic code structure monitoring in vb.net , using system.io.ports.serialport. uses serialport.basestream.beginread , serialport.basestream.endread methods grab information off of port. calls these methods infinitely using action callback until cancellationtoken.iscancellationrequested occurs disrupt process.

it turns out when try cancel loop via cancellationtoken.cancel(), beginread method blocking , cancellation not able through. discovered readtimeout setting built-in serialport class not apply basestream.beginread. issue in remote desktop session. remote server's operating system windows server 2008 r2 standard. i've tried other remote servers windows 8 operating system , ones not have problem.

the internet not helpful in case, after lot of tinkering discovered method fixes problem.

in end needed call serialport.discardinbuffer() before calling cancellationtoken.cancel().

hopefully helps else in future.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -