static NatUtility()
{
EnabledProtocols = new List<NatProtocol>
{
NatProtocol.Upnp,
NatProtocol.Pmp
};
searching = new ManualResetEvent(false);
controllers = new List<ISearcher>();
controllers.Add(UpnpSearcher.Instance);
controllers.Add(PmpSearcher.Instance);
controllers.ForEach(searcher =>
{
searcher.DeviceFound += (sender, args) =>
{
if (DeviceFound != null)
DeviceFound(sender, args);
};
searcher.DeviceLost += (sender, args) =>
{
if (DeviceLost != null)
DeviceLost(sender, args);
};
});
Thread t = new Thread(SearchAndListen);
t.IsBackground = true;
t.Start();
}