Why xbee DataReceived event works only once?

When I push a button,the spider send a data to the CeruinoBee.
But the DataReceived event works only at the first time the CeruinoBee received the data.
Then the xbee DataReceived event does not raise anymore.
What I am missing?

     public partial class Program
    {
        // This method is run when the mainboard is powered up or reset.   
        SerialPort xbee = new SerialPort("COM1", 115200);
        int packet = 0;
        void ProgramStarted()
        {
            xbee.Open();
            xbee.DataReceived += new SerialDataReceivedEventHandler(xbee_DataReceived);
                              
            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");
        }

        void xbee_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            Debug.Print("Data Received");
        }
               
      
    }

try reading all data that’s available in the serial buffer at the time the event handler is entered. It might not like that you don’t do anything to the buffer…

OK, I think I found it for you. http://www.tinyclr.com/forum/topic?id=7692

The serial port you’re using in Gadgeteer land wires up a handler before the open() and this hits another known issue. I don’t know if there’s a way around that, short of pulling out the driver and reverting back to using the non-Gadgeteer serial port objects and handling all the setup yourself.

Thanks Brett.

The DataReceived event handler works well on my spider but CeruinoBee not.

I insert the xbee to the socket on the CeruinoBee directly not Xbee gadgeteer module.
Then I include and using GHI.OSHW.Hardware.LowLevel;

How to do "using the non-Gadgeteer serial port objects " you recommend?

@ Tzu Hsuan - Check this tutorial first:

There are also various examples on Codeshare.

You are using a Gadgeteer template application so you’re using a ProgramStarted() construct not a Main(). That is why I assumed you were using the Gadgeteer XBee module capability; did you add anything to the designer for cerbuino with xbee?

No anything to the designer for cerbuino with xbee,
Why I am using the Gadgeteer template application is that I can use the on board xbee socket and other Gadgeteer module in the same time.
Now I use a timer to monitoring the received data. Its works now.
but don’t understand why the Received Event not works.
And the tutorial Architect provided is useful for me, but do not mention how to do a custom event ?

Thank you guys.