OpenHome.Net.Runner.Runner C# (CSharp) 메소드

Runner() 공개 메소드

public Runner ( int aMsearchTimeSecs ) : System
aMsearchTimeSecs int
리턴 System
        public Runner(int aMsearchTimeSecs)
        {
            iListFrozen = false;
            iDeviceList = new List<ControlPoint.ICpDevice>();
            ControlPoint.CpDeviceList.ChangeHandler added = new ControlPoint.CpDeviceList.ChangeHandler(DeviceAdded);
            ControlPoint.CpDeviceList.ChangeHandler removed = new ControlPoint.CpDeviceList.ChangeHandler(DeviceRemoved);
            ControlPoint.CpDeviceListUpnpServiceType list = new ControlPoint.CpDeviceListUpnpServiceType("upnp.org", "ConnectionManager", 1, added, removed);
            //CpDeviceListUpnpUuid list = new CpDeviceListUpnpUuid("896659847466-a4badbeaacbc-737837", added, removed);
            Semaphore sem = new Semaphore(0, 1);
            sem.WaitOne(aMsearchTimeSecs * 1000);
            iListFrozen = true;

            InvokeSync();
            // Note that following tests handle the device list changing (i.e. devices being switched on/off) badly

            Console.Write("\n\n");
            int count = iDeviceList.Count;
            DateTime startTime = DateTime.Now;
            PollInvoke();
            DateTime endTime = DateTime.Now;
            uint avgActions = 0;
            if (count > 0)
            {
                avgActions = (uint)(iActionCount / count);
            }
            double secs = endTime.Subtract(startTime).TotalSeconds;
            Console.Write("\n" + iActionCount + " actions invoked on " + count + " devices (avg " + avgActions + ") in " + secs + " seconds\n\n");

            Console.Write("\n\n");
            startTime = DateTime.Now;
            PollSubscribe();
            endTime = DateTime.Now;
            uint avgSubscriptions = 0;
            if (count > 0)
            {
                avgSubscriptions = (uint)(iSubscriptionCount / count);
            }
            secs = endTime.Subtract(startTime).TotalSeconds;
            Console.Write("\n" + iSubscriptionCount + " subscriptions on " + count + " devices (avg " + avgSubscriptions + ") in " + secs + " seconds\n\n");

            list.Dispose();
            lock (this)
            {
                for (int i = 0; i < iDeviceList.Count; i++)
                {
                    iDeviceList[i].RemoveRef();
                }
            }
            Console.Write("Tests completed\n");
        }