public ThreadCenter() { _th = new Thread((ThreadStart) delegate { while (_death == false) { operation_d operation; lock (SYNCROOT) { operation = _operations.dequeue(); } if (operation == null) { _evCatnap.waitForMillis(2000); } else { try { operation(); } catch { } } } }); _th.Start(); }
public void approve() { if (_enterEv.waitForMillis(0)) { _approveEv.set(); _leaveEv.waitForever(); } }
public Sender(string ident) { _n = new Nectar2(ident); _evDoSend = new NamedEventPair(); _th = new Thread((ThreadStart) delegate { while (_death == false) { byte[] message; lock (SYNCROOT) { if (_messages.Count == 0) { message = null; _sending = false; } else { message = _messages.Dequeue(); _sending = true; } } if (message == null) { _evDoSend.waitForMillis(2000); } else { foreach (byte chr in message) { for (int bit = 0; bit < 8; bit++) { if ((chr & (1 << bit)) != 0) { _n.set((E_INDEX)((int)E_INDEX.E_BIT_0 + bit)); } } _n.get(E_INDEX.E_RECV); // clear _n.set(E_INDEX.E_SEND); if (syncRecv() == false) // ? 送信タイムアウト { lock (SYNCROOT) { _messages.Clear(); // 全部失敗扱い。 } break; } } } } }); _th.Start(); }