.Net 2.0 B1 Serial port problem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anyone had this problem? It seems IO.Ports.SerialPort generates an "The I/O
operation has been aborted because of either a thread exit or an application
request" exception if you try to close it when it's receiving lots of data.

The following VB.Net console program reliably fails if there's a device
sending full speed serial data at it. It works fine if the data is being
sent more slowly. (less often)
---------------------------------------------
Imports System.Threading
Imports System.IO.Ports

Module Module1

Sub Main()
Dim comPort As System.IO.Ports.SerialPort

Console.WriteLine("Creating new serial port")
comPort = New IO.Ports.SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One)

Console.WriteLine("Opening")
comPort.Open()

Thread.Sleep(1000)

Console.WriteLine("Closing")

'The following line often fails with: The I/O operation has been
aborted because of either a thread exit or an application request.

comPort.Close()
End Module
 
Yeah, I think it's broken.

Does the same in C#... but only under load, this produces the same effect
(It's too bad, we realy need serial support):

using System;
using System.IO.Ports;
using System.Threading;

namespace fetserial
{
class Program
{
static void Main(string[] args)
{
SerialPort sp = new SerialPort("COM1", 9600, Parity.None, 8,
StopBits.One);
while (true)
{
Console.WriteLine("Test Loop");
sp.Open();
Thread.Sleep(1000);
sp.Close();
Thread.Sleep(1000);
}
}
}
}
 
Back
Top