public Byte[] WriteRead(Byte[] bytesToSend){ this.FrameReceived += Device_FrameReceived; this.Write(bytesToSend); Boolean signaled = this.autoResetEvent.WaitOne(); this.FrameReceived -= Device_FrameReceived; if (signaled) { return this.incomingBytes; } else { return null; }}
private void Device_FrameReceived(Object sender, FrameReceivedEventAgs e){ this.incomingBytes = e.Frame; this.autoResetEvent.Set();}Using the WriteRead-Method before calling Thread.Sleep, in the Main-Method, the mechanism works. Once Thread.Sleep is called, the mechanism won't work anymore. I attached an example application which demonstrate the problem. Maybe someone is willing to explain why the demonstration application don't work, and how to fix the problem. To test the application, some random byte have to be generated on COM1. P.S: It's a netduino Mini Application Projects, since I'm not using any netduino Mini specific code, it should run on any netduino, or not?