void SendArpGenericInBackground(UInt64 destinationEthernetAddress, ArpOperation arpOperation, UInt64 targetPhysicalAddress, UInt32 targetProtocolAddress) { ArpGenericData arpGenericData = new ArpGenericData(destinationEthernetAddress, arpOperation, targetPhysicalAddress, targetProtocolAddress); _sendArpGenericInBackgroundQueue.Enqueue(arpGenericData); _sendArpGenericInBackgroundEvent.Set(); }
void SendArpGenericThread() { while (true) { _sendArpGenericInBackgroundEvent.WaitOne(); // if we have been disposed, shut down our thread now. if (_isDisposed) { return; } while ((_sendArpGenericInBackgroundQueue != null) && (_sendArpGenericInBackgroundQueue.Count > 0)) { try { ArpGenericData arpGenericData = (ArpGenericData)_sendArpGenericInBackgroundQueue.Dequeue(); SendArpGeneric(arpGenericData.DestinationEthernetAddress, arpGenericData.ArpOperaton, arpGenericData.TargetPhysicalAddress, arpGenericData.TargetProtocolAddress, Int64.MaxValue); } catch (InvalidOperationException) { // reply queue was empty } // if we have been disposed, shut down our thread now. if (_isDisposed) { return; } } } }