public static Process StartProcess(AllocateOptions options)
        {
            var filePath = Assembly.GetEntryAssembly().Location;
            var argsStr  = Parser.Default.FormatCommandLine(options);

            return(Process.Start(filePath, argsStr));
        }
示例#2
0
        private static int StartAllocation(AllocateOptions options)
        {
            Console.WriteLine($"Allocation started: duration = {options.Duration}, mode = {options.AllocationMode}");
            var spinWait   = new SpinWait();
            var heavyMetal = new ObjectAllocator(options.AllocationMode);

            heavyMetal.Start();

            var timer = new Timer(state =>
            {
                heavyMetal.Stop();
            }, null, (long)options.Duration.TotalMilliseconds, Timeout.Infinite);

            while (heavyMetal.IsRunning)
            {
                spinWait.SpinOnce();
            }

            Console.WriteLine("Allocation ended");

            return(0);
        }