Port.Open() hangs

Last post 10-17-2007 3:42 by Anonymous. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 09-07-2007 15:33

    Port.Open() hangs

    Hello everyone!
    I'm developing a application that sends and receives some data via Bluetooth virtual port.I'm using CF 2.0 SP2 and win ce 4.2(Pocket PC 2003). At the beginning I was using System.IO.Serial but when I tried to set the BaudRate to the desired value(115200) I started looking for other solution. So I tried using OpenNETCF.IO.Serial. Here is the code I use to init the port:
    DetailedPortSettings portSettings = new HandshakeNone();
    portSettings.BasicSettings.BaudRate = BaudRates.CBR_115200;
    Port serialPort = new Port("COM6:", portSettings, bufferSize, bufferSize);
    serialPort.DataReceived += new Port.CommEvent(serialPort_DataReceived);
    serialPort.InputLen = 14;
    serialPort.RThreshold = 11;
    serialPort.SThreshold = 8;
    serialPort.Open();
    The application hangs on Open() call. I've done some sniffing and it seems that line:
    AutoResetEvent rxevent = new AutoResetEvent(false); in
    private void CommEventThread()
    is to blame. The app never passes this line so it fails to release threadStarted. Any clue what is wrong?
  • 10-17-2007 3:42 In reply to

    Re: Port.Open() hangs

    In case anyone is interested I've found the solution. In my software I was using the Singleton implementation described here, fourth version:
    http://www.yoda.arachsys.com/csharp/singleton.html
    I changed the Singleton implementation into the "traditional", incorrect one(1st on the page above) and the problem stopped appearing. I don't know exactly what caused the problem and now I'm simply happy that it works ;)
Page 1 of 1 (2 items)