Beispiel #1
0
        public static void Callback_OnPacketArrival(object sender, SharpPcap.CaptureEventArgs e)
        {
            Boolean shouldEventHandlerCalled = true;

            lock (_syncLock)
            {
                if (_stoppingCapture)
                {
                    shouldEventHandlerCalled = false;
                }
            }

            if (shouldEventHandlerCalled)
            {
                // Call Event handler of FormMain (in the context of FormMain thread)
                PacketArrival del = MainForm.OnPacketArrival;
                MainForm.Invoke(del, e);
            }
        }
        private void ReadNextLoop()
        {
            PcapHeader packetHeader;

            System.Byte[]      arr;
            IntPtr             i, i1;
            PCAP_NEXT_EX_STATE pcap_next_ex_state;

            while (true)
            {
                packetHeader       = null;
                arr                = null;
                pcap_next_ex_state = ReadNextInternal(out packetHeader, out arr, out i, out i1);
                if (pcap_next_ex_state == PCAP_NEXT_EX_STATE.SUCCESS)
                {
                    if (PacketArrival != null)
                    {
                        PacketArrival.Invoke(this, packetHeader, arr);
                    }
                }
            }
        }
Beispiel #3
0
 protected virtual void OnPacketArrival(PacketArrivedEventArgs e)
 {
     PacketArrival?.Invoke(this, e);
 }
Beispiel #4
0
 public event PacketArrivedEventHandler PacketArrival;//声明时间句柄函数
 private void OnPacketArrival(PacketArrivedEventArgs e)
 {
     PacketArrival?.Invoke(this, e);//触发事件
 }
Beispiel #5
0
 protected virtual void OnPacketArrival(Packet packet)
 {
     PacketArrival?.Invoke(this, packet);
 }