All pastes #227241 Raw Edit

Anonymous

public text v1 · immutable
#227241 ·published 2006-10-29 03:37 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Tamir.IPLib;

namespace L2HelperClient
{
    class packetCapture
    {
        /// <summary>
        /// The listener threads to listen to each device
        /// </summary>
        private static Thread[] listenerThreads;

        /// <summary>
        /// The devices installed and detected on the system.
        /// </summary>
        private static PcapDeviceList devices;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="devs">the list of devices</param>
        /// <param name="main">instance of the main window</param>
        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");
        }

        /// <summary>
        /// Set devices
        /// </summary>
        /// <param name="devs">the list of devices</param>
        public static void setDevices(PcapDeviceList devs) 
        {
            devices = devs;
        }
    }
}