Beispiel #1
0
        static int Main()
        {
            // TODO: Migrate to Main async method with C# 7.1

            BitResult result = null;

            try
            {
                var container = DependencyInjectionContainer.BuildDefault();
                var program   = new Program(container);
                var task      = program.Run();

                task.Wait();

                if (!task.IsCompletedSuccessfully)
                {
                    throw task.Exception;
                }

                result = task.Result;
            }
            catch (Exception exception)
            {
                result = new BitResult
                {
                    ResultCode    = exception.HResult,
                    ResultMessage = exception.Message
                };
            }
            finally
            {
                if (result == null)
                {
                    result = new BitResult
                    {
                        ResultCode    = -1,
                        ResultMessage = "Fatal unespected exception."
                    };
                }
            }

            // TODO: Print messages
            return(result.ResultCode);
        }