Esempio n. 1
0
        private static int WaitToFinishOrTimeout(RemoteProcess process, TimeSpan timeout)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();

            while (!process.HasExited() && timer.Elapsed < timeout)
            {
                Thread.Sleep(2000);
            }

            return(!process.HasExited() ? ForceProcessKill(process) : process.GetExitCode());
        }
Esempio n. 2
0
	    private static int WaitToFinishOrTimeout(RemoteProcess process, TimeSpan timeout)
	    {
	        Stopwatch timer = new Stopwatch();
	        timer.Start();

	        while (!process.HasExited() && timer.Elapsed < timeout)
	        {
	            Thread.Sleep(2000);
	        }

            return !process.HasExited() ? ForceProcessKill(process) : process.GetExitCode();
	    }
Esempio n. 3
0
        static int Main(string[] args)
        {
            try
            {
                if (args.Length != 4)
                {
                    Usage();
                    return(1);
                }

                string platformId = args[0];
                string deviceId   = args[1];
                string packageID;

                switch (args[2])
                {
                case "2.0":
                    packageID = NetCf20PackageId;
                    break;

                case "3.5":
                    packageID = NetCf35PackageId;
                    break;

                default:
                    packageID = args[2];
                    break;
                }

                string cabName = args[3];

                // Get the datastore object
                var dsmgr = new DatastoreManager(1033);

                var platform = dsmgr.GetPlatform(new ObjectId(platformId));
                var device   = platform.GetDevice(new ObjectId(deviceId));

                Console.WriteLine("Connecting to device...");
                device.Connect();

                FileDeployer fileDeployer = device.GetFileDeployer();

                Console.WriteLine("Deploying package...");
                fileDeployer.DownloadPackage(new ObjectId(packageID));

                Console.WriteLine("Installing package...");
                RemoteProcess installer = device.GetRemoteProcess();
                installer.Start("wceload.exe", cabName);
                while (installer.HasExited() != true)
                {
                    System.Threading.Thread.Sleep(1000);
                }
                var exitCode = installer.GetExitCode();
                if (exitCode != 0)
                {
                    Console.WriteLine("Installation failed. Exit code: {0}", exitCode);
                }
                else
                {
                    Console.WriteLine("Installation succeeded.");
                }
                return(exitCode);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR: {0}", ex);
                return(1);
            }
        }