Using pcap.net with wpf

Sep 10, 2011 at 1:59 PM

This isn't a direct pcap.net issue but I was hoping I could get some help on it regardless.

I want to use pcap.net in a wpf application but when I initialize pcap.net the main window of my application never shows. If I comment out the last line of the initialization code - communicator.ReceivePackets(0, PacketHandler); and then run the program the window shows up fine. So any ideas on why my window never appears once the ReceivePacket function is called? Im guessing because the program is stuck in the pcap.net event loop. If so, have you any suggestions on how I use pcap.net in a wpf application?

Cheers.

Sep 12, 2011 at 10:15 AM

communicator.RecievePackets() is a blocking call, that is why it's not working here for you.

 

You need to run this command in another thread, separate to the WPF thread. There is some code for doing this in an old discussion here: http://pcapdotnet.codeplex.com/discussions/224992