• <legend id='37O6f'><style id='37O6f'><dir id='37O6f'><q id='37O6f'></q></dir></style></legend>

      1. <i id='37O6f'><tr id='37O6f'><dt id='37O6f'><q id='37O6f'><span id='37O6f'><b id='37O6f'><form id='37O6f'><ins id='37O6f'></ins><ul id='37O6f'></ul><sub id='37O6f'></sub></form><legend id='37O6f'></legend><bdo id='37O6f'><pre id='37O6f'><center id='37O6f'></center></pre></bdo></b><th id='37O6f'></th></span></q></dt></tr></i><div id='37O6f'><tfoot id='37O6f'></tfoot><dl id='37O6f'><fieldset id='37O6f'></fieldset></dl></div>
      2. <tfoot id='37O6f'></tfoot>

        <small id='37O6f'></small><noframes id='37O6f'>

        • <bdo id='37O6f'></bdo><ul id='37O6f'></ul>

        控制台应用程序在鼠标单击时冻结

        时间:2023-08-27
          <tfoot id='TbHXg'></tfoot>
          • <bdo id='TbHXg'></bdo><ul id='TbHXg'></ul>
              <legend id='TbHXg'><style id='TbHXg'><dir id='TbHXg'><q id='TbHXg'></q></dir></style></legend>

              <i id='TbHXg'><tr id='TbHXg'><dt id='TbHXg'><q id='TbHXg'><span id='TbHXg'><b id='TbHXg'><form id='TbHXg'><ins id='TbHXg'></ins><ul id='TbHXg'></ul><sub id='TbHXg'></sub></form><legend id='TbHXg'></legend><bdo id='TbHXg'><pre id='TbHXg'><center id='TbHXg'></center></pre></bdo></b><th id='TbHXg'></th></span></q></dt></tr></i><div id='TbHXg'><tfoot id='TbHXg'></tfoot><dl id='TbHXg'><fieldset id='TbHXg'></fieldset></dl></div>
                <tbody id='TbHXg'></tbody>
            • <small id='TbHXg'></small><noframes id='TbHXg'>

                1. 本文介绍了控制台应用程序在鼠标单击时冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个非常简单的 C# 控制台应用程序,它显示一些文本和循环等待输入,直到按下转义键或提供超时时间.

                  I have a very simple C# console application that displays some text and loops waiting for input until the escape key is pressed or the timeout period is served.

                  using System;
                  using System.Collections.Generic;
                  using System.Diagnostics;
                  using System.Linq;
                  using System.Text;
                  using System.Threading;
                  
                  namespace SampleApp
                  {
                      public static class Program
                      {
                          public static void Main (string [] args)
                          {
                              var key = new ConsoleKeyInfo();
                              var watch = Stopwatch.StartNew();
                              var timeout = TimeSpan.FromSeconds(5);
                  
                              Console.WriteLine("Press escape to return to the previous screen...");
                              Console.WriteLine();
                  
                              do
                              {
                                  Console.WriteLine("This screen will automatically close in " + ((timeout + TimeSpan.FromSeconds(1)) - watch.Elapsed).ToString(@"hh:mm:ss") + ".");
                  
                                  if (Console.KeyAvailable) { key = Console.ReadKey(true); }
                                  else { Thread.Sleep(TimeSpan.FromSeconds(0.10D)); }
                              }
                             while ((key.Key != ConsoleKey.Escape) && (timeout > (watch.Elapsed - TimeSpan.FromSeconds(0.5D))));
                  
                              watch.Stop();
                          }
                      }
                  }
                  

                  这很好用,但是如果我用鼠标单击控制台应用程序(例如获得焦点),屏幕上的所有活动都会冻结,直到我右键单击或按退出键.在此期间,控制台的标题也更改为 "Select AppName",假设 "AppName" 是之前的标题.

                  This works fine but if I click on the console app with the mouse (to gain focus for example), all activity on the screen freezes until I right click or press escape. During this time, the title of the console also changes to "Select AppName" assuming "AppName" was the title before.

                  如果我先右键单击控制台,do {...} while (); 循环似乎会发疯并打印出很多额外的行.

                  If I right-click ion the console first, the do {...} while (); loop seems to go crazy and prints a lot of extra lines.

                  由于我不知道控制台的这种行为,不知道要问什么.这是可以预料的吗?如果是这样,我可以改变这种行为吗?如果没有,任何解决方法的建议都将不胜感激.

                  Since I am not aware of this behavior of the console, not sure what to ask. Is this to be expected? If so, can I change this behavior? If not, any suggestions for workarounds would be appreciated.

                  推荐答案

                  使用上面 Hans 的评论解决了这个问题.

                  The issue was solved using Hans' comment above.

                  显然,出于某种原因,在控制台默认值(Alt + Space、默认值、选项、编辑选项、快速编辑模式)中设置了快速编辑模式.取消选中即可解决问题.

                  Apparently, Quick Edit Mode was set in the console defaults (Alt + Space, Defaults, Options, Edit Options, Quick Edit Mode) for some reason. Unchecking that resolved the issue.

                  这篇关于控制台应用程序在鼠标单击时冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 Winforms 控制 cmd.exe 下一篇:如何在我的 C# 控制台应用程序中使用命令行参数

                  相关文章

                  最新文章

                2. <tfoot id='F1Ggn'></tfoot>

                      <legend id='F1Ggn'><style id='F1Ggn'><dir id='F1Ggn'><q id='F1Ggn'></q></dir></style></legend>

                      <small id='F1Ggn'></small><noframes id='F1Ggn'>

                      <i id='F1Ggn'><tr id='F1Ggn'><dt id='F1Ggn'><q id='F1Ggn'><span id='F1Ggn'><b id='F1Ggn'><form id='F1Ggn'><ins id='F1Ggn'></ins><ul id='F1Ggn'></ul><sub id='F1Ggn'></sub></form><legend id='F1Ggn'></legend><bdo id='F1Ggn'><pre id='F1Ggn'><center id='F1Ggn'></center></pre></bdo></b><th id='F1Ggn'></th></span></q></dt></tr></i><div id='F1Ggn'><tfoot id='F1Ggn'></tfoot><dl id='F1Ggn'><fieldset id='F1Ggn'></fieldset></dl></div>

                      • <bdo id='F1Ggn'></bdo><ul id='F1Ggn'></ul>