久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

    <bdo id='jhURL'></bdo><ul id='jhURL'></ul>
  • <i id='jhURL'><tr id='jhURL'><dt id='jhURL'><q id='jhURL'><span id='jhURL'><b id='jhURL'><form id='jhURL'><ins id='jhURL'></ins><ul id='jhURL'></ul><sub id='jhURL'></sub></form><legend id='jhURL'></legend><bdo id='jhURL'><pre id='jhURL'><center id='jhURL'></center></pre></bdo></b><th id='jhURL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='jhURL'><tfoot id='jhURL'></tfoot><dl id='jhURL'><fieldset id='jhURL'></fieldset></dl></div>
    <tfoot id='jhURL'></tfoot>
      <legend id='jhURL'><style id='jhURL'><dir id='jhURL'><q id='jhURL'></q></dir></style></legend>

      1. 在任何未處理的異常的情況下退出應用程序

        Exit the application in case of any unhandled exception(在任何未處理的異常的情況下退出應用程序)
          • <bdo id='7gOYF'></bdo><ul id='7gOYF'></ul>

            1. <i id='7gOYF'><tr id='7gOYF'><dt id='7gOYF'><q id='7gOYF'><span id='7gOYF'><b id='7gOYF'><form id='7gOYF'><ins id='7gOYF'></ins><ul id='7gOYF'></ul><sub id='7gOYF'></sub></form><legend id='7gOYF'></legend><bdo id='7gOYF'><pre id='7gOYF'><center id='7gOYF'></center></pre></bdo></b><th id='7gOYF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='7gOYF'><tfoot id='7gOYF'></tfoot><dl id='7gOYF'><fieldset id='7gOYF'></fieldset></dl></div>

            2. <small id='7gOYF'></small><noframes id='7gOYF'>

              <tfoot id='7gOYF'></tfoot>
                    <tbody id='7gOYF'></tbody>
                  <legend id='7gOYF'><style id='7gOYF'><dir id='7gOYF'><q id='7gOYF'></q></dir></style></legend>
                  本文介紹了在任何未處理的異常的情況下退出應用程序的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  [我知道網上有 100 多個類似的問題,但我仍然無法找到解決此問題的有效解決方案,因此將其發布.]

                  我有一個 c# Win-Form 應用程序.該應用程序用于通過 FTP 從另一臺服務器下載圖像.

                  I have a c# Win-Form application. The application is used for downloading images via FTP from another server.

                  在任務調度程序的幫助下,應用程序每天運行 3 次并下載圖像,然后自動關閉.

                  With the help of a task scheduler, the application runs 3 times a day and downloads the images and after that it closes automatically.

                  去年它運行良好,但是,自今年年初以來,我們收到了來自應用程序的請求超時"或操作超時"等未處理的異常.

                  It used to work fine last year, however, since the beginning of this year, we are getting unhandled exception like "request timed out" or "operation timed out" from the application.

                  因此,應用程序不會自動關閉,而是顯示一個帶有繼續"和退出"按鈕的窗口對話框.

                  Thus instead of the application getting closed automatically, it shows a windows dialog with "continue" and "quit" button.

                  我的要求是應用程序應該自動關閉,以防引發任何未處理的異常.

                  My requirement is that the application should close automatically in case any unhandled exception is thrown.

                  我在我的 program.cs 中編寫了以下代碼來處理這個問題.但是,這也不起作用,我仍然收到異常窗口.

                  I have written the following code in my program.cs to handle this. However, this is also not working and I am still getting exceptions window.

                      [STAThread]
                      static void Main()
                      {
                          AppDomain currentDomain = AppDomain.CurrentDomain;
                          currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
                          Application.EnableVisualStyles();
                          Application.SetCompatibleTextRenderingDefault(false);
                          Application.Run(new Form1());
                      }
                      static void MyHandler(object sender, UnhandledExceptionEventArgs args)
                      {
                          System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
                          System.Windows.Forms.Application.Exit();
                          System.Environment.Exit(0);
                          proc.Kill();
                          return;
                      }
                  

                  推薦答案

                  您可能需要訂閱幾個事件以確保捕獲所有可能的異常:

                  There are several events to which you may need to subscribe to ensure that you catch EVERY possible exception:

                  Application.ThreadException += yourThreadExceptionHandler;
                  AppDomain.CurrentDomain.UnhandledException += yourUnhandledExceptionHandler;
                  TaskScheduler.UnobservedTaskException += yourUnobservedTaskExceptionHandler;
                  

                  當然,您還應該在程序主體周圍有一個 try/catch:

                  And of course you should also have a try/catch around the body of the program:

                  public static void Main()
                  {
                      try
                      {
                          runProgram();
                      }
                  
                      catch (Exception exception)
                      {
                          // Your main exception handler.
                      }
                  }
                  

                  您可以使用所有附加的處理程序調用的通用異常處理機制,以避免重復代碼.UnobservedTaskException 可能是您想要以不同方式處理的事情(記錄它,否則可能會忽略).

                  You can have a common exception handling mechanism that all your attached handlers call, to avoid duplicated code. UnobservedTaskException might be something you want to handle differently (log it and otherwise ignore, perhaps).

                  這篇關于在任何未處理的異常的情況下退出應用程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                  onClick event for Image in Unity(Unity中圖像的onClick事件)
                  Running Total C#(運行總 C#)
                  Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                  asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                  Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                • <tfoot id='wRiC8'></tfoot>
                • <legend id='wRiC8'><style id='wRiC8'><dir id='wRiC8'><q id='wRiC8'></q></dir></style></legend>
                      <bdo id='wRiC8'></bdo><ul id='wRiC8'></ul>

                          <tbody id='wRiC8'></tbody>

                          • <small id='wRiC8'></small><noframes id='wRiC8'>

                          • <i id='wRiC8'><tr id='wRiC8'><dt id='wRiC8'><q id='wRiC8'><span id='wRiC8'><b id='wRiC8'><form id='wRiC8'><ins id='wRiC8'></ins><ul id='wRiC8'></ul><sub id='wRiC8'></sub></form><legend id='wRiC8'></legend><bdo id='wRiC8'><pre id='wRiC8'><center id='wRiC8'></center></pre></bdo></b><th id='wRiC8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wRiC8'><tfoot id='wRiC8'></tfoot><dl id='wRiC8'><fieldset id='wRiC8'></fieldset></dl></div>
                            主站蜘蛛池模板: aa级毛片毛片免费观看久 | 国产小视频精品 | 亚州成人 | 国产精品久久国产精品 | 亚洲国产精品激情在线观看 | 亚洲精品乱码久久久久久按摩 | 亚洲香蕉在线视频 | 久久久久国产精品一区三寸 | 久久国| 精品欧美一区二区在线观看欧美熟 | 久久大陆 | 成人欧美一区二区三区在线观看 | 色网站视频 | 亚洲欧美日本在线 | 成人日韩 | 欧美第一页| 久久久久久一区 | 中文在线a在线 | 欧美一级久久久猛烈a大片 日韩av免费在线观看 | 欧美看片| 天天草av | av在线免费播放 | 五月免费视频 | 久久久久久网站 | 国产一区二区电影 | 国产欧美日韩精品一区二区三区 | 色小姐综合网 | 亚洲免费在线视频 | 久草网址| 久久夜视频 | 日韩欧美一区二区三区免费看 | 免费在线视频a | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 午夜小视频在线播放 | 黄色国产视频 | 91精品国产91久久久 | 毛片在线视频 | 成人在线播放网站 | 国产污视频在线 | 国产欧美日韩精品一区二区三区 | 国产高清精品一区二区三区 |