using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Windows.Forms; using Tamir.IPLib; namespace L2HelperClient { class packetCapture { /// /// The listener threads to listen to each device /// private static Thread[] listenerThreads; /// /// The devices installed and detected on the system. /// private static PcapDeviceList devices; /// /// Constructor /// /// the list of devices /// instance of the main window public packetCapture(PcapDeviceList devs) { setDevices(devs); } public void createListenerThreads() { int i = 0; foreach (PcapDevice devs in devices) { Console.WriteLine("[" + i + "]Creating thread..."); ThreadStart ts = new ThreadStart(packetCapture.beginThread); Console.WriteLine("ThreadStart created..."); try { listenerThreads[i] = new Thread(ts); Console.WriteLine("[" + i + "]Created Thread!!!"); } catch (Exception e) { Console.WriteLine(e); } // next line necassary? listenerThreads[i].SetApartmentState(ApartmentState.MTA); listenerThreads[i].Name = i.ToString(); listenerThreads[i].Start(); Console.WriteLine("[" + i + "]Started Thread."); i++; } } private static void beginThread() { Console.WriteLine("WORK DAMMIT"); } /// /// Set devices /// /// the list of devices public static void setDevices(PcapDeviceList devs) { devices = devs; } } }