コード例 #1
0
ファイル: Program.cs プロジェクト: SimonPilkington/mpupdater
        static SingleThreadedExecutionMessageQueue SetupMessageQueue()
        {
            var messageQueue = new SingleThreadedExecutionMessageQueue();

            ConsoleExt.ConsoleMessageQueue = messageQueue;
            SynchronizationContext.SetSynchronizationContext(messageQueue.DefaultSynchronizationContext);
            return(messageQueue);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: SimonPilkington/mpupdater
        static void Main(string[] args)
        {
            Console.CursorVisible = false;

            Console.Title = $"Video nonsense updater";
            Console.WriteLine($"Video nonsense updater - version {Assembly.GetExecutingAssembly().GetName().Version} {architecture}");
            Console.WriteLine();

            bool doUpdate = true;

            if (args.Length > 0)
            {
                doUpdate = false;

                OptionSet commandLineOptions = null;
                commandLineOptions = new OptionSet()
                {
                    { "h|?|help", "Show this help.", _ => commandLineOptions.WriteOptionDescriptions(Console.Out) },
                    { "c|configure", "Configure the program.", _ =>
                      {
                          SetupConfig();

                          doUpdate = ConsolePrompt.Create("Settings saved. Update now?");
                          Console.WriteLine();
                      } }
                };

                commandLineOptions.Parse(args);
            }

            if (doUpdate)
            {
                SingleThreadedExecutionMessageQueue messageQueue = SetupMessageQueue();

                Task update = UpdateAsync();
                update.ContinueWith(_ => messageQueue.TerminateMessageLoop());
                messageQueue.EnterMessageLoop();
            }

            Console.ReadKey();
        }
コード例 #3
0
 public SingleThreadSynchronizationContext(SingleThreadedExecutionMessageQueue messageQueue)
 {
     actionMessageQueue = messageQueue;
 }