コード例 #1
0
 private void cancelButton_Click(object sender, EventArgs e)
 {
     if (selectedHeadline != null && selectedHeadline.IsFetching == true)
     {
         HeadlineManager.CancelFetchChannelsAsync(selectedHeadline);
     }
 }
コード例 #2
0
        static void Main()
        {
            // エラーハンドラ登録
            System.Threading.Thread.GetDomain().UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e)
            {
                Exception ex = e.ExceptionObject as Exception;
                SaveExceptionLog(ex);
            };

            try
            {
                // プラグインを検索する
                HeadlinePluginManager.FindPlugins();

                // 設定を読み込む
                UserSettingAdapter.Load();

                // ヘッドラインを読み込む
                HeadlineManager.Load();

                Application.Run(new MainForm());

                #region 番組取得のスレッドを終了する

                // ヘッドライン取得処理の中止
                HeadlineManager.CancelFetchChannelsAsync();

                // スレッドが中止されるまで待つ
                // 1秒待ってスレッドが中止されないようなら、スレッドの中止を待たずにここを抜ける
                for (int i = 0; HeadlineManager.IsExistBusyFetchChannelAsync() == true && i < 10; ++i)
                {
                    System.Threading.Thread.Sleep(100);
                }

                #endregion // 番組取得のスレッドを終了する
            }
            catch (Exception ex)
            {
                SaveExceptionLog(ex);

                // 例外の再送
                throw ex;
            }
            finally
            {
                // ヘッドラインを保存する
                HeadlineManager.Save();

                // 設定を保存する
                UserSettingAdapter.Save();
            }
        }