Example #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public <R> java.util.concurrent.Future<R> executeDontWait(final WorkerCommand<T, R> cmd)
        public virtual Future <R> ExecuteDontWait <R>(WorkerCommand <T, R> cmd)
        {
            _executionState = ExecutionState.RequestedExecution;
            return(_commandExecutor.submit(() =>
            {
                _executionState = ExecutionState.Executing;
                try
                {
                    return cmd.DoWork(StateConflict);
                }
                finally
                {
                    _executionState = ExecutionState.Executed;
                }
            }));
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public <R> R execute(WorkerCommand<T, R> cmd, long timeout, java.util.concurrent.TimeUnit unit) throws Exception
        public virtual R Execute <R>(WorkerCommand <T, R> cmd, long timeout, TimeUnit unit)
        {
            Future <R> future  = ExecuteDontWait(cmd);
            bool       success = false;

            try
            {
                AwaitStartExecuting();
                R result = future.get(timeout, unit);
                success = true;
                return(result);
            }
            finally
            {
                if (!success)
                {
                    future.cancel(true);
                }
            }
        }
Example #3
0
        public static void Main(string[] args)
        {
            #if DEBUG
            if (args.Any(a => string.Equals(a, "--debug", StringComparison.Ordinal)))
            {
                args = args.Where(a => !string.Equals(a, "--debug", StringComparison.Ordinal)).ToArray();
                Console.WriteLine($"Waiting for debugger. Process ID: {Process.GetCurrentProcess().Id}");
                Console.WriteLine("Press ENTER to continue");
                Console.ReadLine();
            }
            #endif

            var app = new CommandLineApplication();
            app.Description = "Crank's Revenge";
            app.HelpOption("-h|--help");

            LocalCommand.Register(app);
            AgentCommand.Register(app);
            WorkerCommand.Register(app);
            ServerCommand.Register(app);

            app.Command("help", cmd =>
            {
                var commandArgument = cmd.Argument("<COMMAND>", "The command to get help for.");

                cmd.OnExecute(() =>
                {
                    app.ShowHelp(commandArgument.Value);
                    return(0);
                });
            });

            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(0);
            });

            app.Execute(args);
        }
Example #4
0
 public void AddCommand(WorkerCommand command)
 {
     Commands.Add(command);
 }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public <R> R execute(WorkerCommand<T, R> cmd) throws Exception
        public virtual R Execute <R>(WorkerCommand <T, R> cmd)
        {
            return(ExecuteDontWait(cmd).get());
        }