static SingleThreadedExecutionMessageQueue SetupMessageQueue() { var messageQueue = new SingleThreadedExecutionMessageQueue(); ConsoleExt.ConsoleMessageQueue = messageQueue; SynchronizationContext.SetSynchronizationContext(messageQueue.DefaultSynchronizationContext); return(messageQueue); }
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(); }
public SingleThreadSynchronizationContext(SingleThreadedExecutionMessageQueue messageQueue) { actionMessageQueue = messageQueue; }