Thread.EndCriticalRegion メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Thread.EndCriticalRegion メソッドの意味・解説 

Thread.EndCriticalRegion メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

スレッド中止または処理されない例外影響現在のタスクだけに及ぶコード領域実行が入ることをホスト通知します

名前空間: System.Threading
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Sub EndCriticalRegion
Thread.EndCriticalRegion
public static void EndCriticalRegion
 ()
public:
static void EndCriticalRegion ()
public static void EndCriticalRegion
 ()
public static function EndCriticalRegion
 ()
解説解説
メモメモ

このメソッド適用される HostProtectionAttribute 属性Resources プロパティの値は、Synchronization または ExternalThreading です。HostProtectionAttribute は、デスクトップ アプリケーション (一般的にはアイコンダブルクリックコマンド入力、またはブラウザURL入力して起動するアプリケーション) には影響しません。詳細については、HostProtectionAttribute クラストピックまたは「SQL Server プログラミングホスト保護属性」を参照してください

Microsoft® SQL Server "Yukon" などの共通言語ランタイム (CLR: Common Language Runtime) のホストは、重大なコード領域でのエラー重大でないコード領域でのエラーに対して異なポリシー設定できます重大な領域とは、スレッド中止または処理されない例外影響現在のタスク以外にも及ぶ可能性がある領域です。これに対し重大でないコード領域内での中止またはエラーは、エラー発生したタスクだけに影響します

たとえば、ロック保持している間にメモリ割り当てるタスクがあると仮定します。メモリ割り当て失敗した場合AppDomain安定性確保するためには現在のタスク中止するだけでは不十分です。これは、同じロック待機している他のタスクがそのドメイン内に存在する可能性があるためです。現在のタスク終了した場合に、他のタスクデッドロック状態になる可能性あります

重大な領域障害発生した場合潜在的に不安定な状態で実行継続する危険を冒すよりも AppDomain 全体アンロードすることをホスト決定することがありますコード重大な領域に入ることをホスト通知するには、BeginCriticalRegion を呼び出します。重大でないコード領域実行が戻るときにはEndCriticalRegion呼び出します。

SQL Server "Yukon" で実行するコード内でこのメソッド使用するには、ホスト保護レベル最大にしてコード実行する必要があります

使用例使用例

BeginCriticalRegion メソッドおよび EndCriticalRegion メソッド使用してコード ブロック重大な領域重大でない領域分割する例を次に示します

Imports System.Threading

Public Class MyUtility
    Public Sub PerformTask() 
        ' Code in this region can be aborted without affecting
        ' other tasks.
        '
        Thread.BeginCriticalRegion()
        '
        ' The host might decide to unload the application domain
        ' if a failure occurs in this code region.
        '
        Thread.EndCriticalRegion()
        ' Code in this region can be aborted without affecting
        ' other tasks.
    End Sub
End Class 
using System.Threading;

public class MyUtility
{
    public void PerformTask()
    {
        // Code in this region can be aborted without affecting
        // other tasks.
        //
        Thread.BeginCriticalRegion();
        //
        // The host might decide to unload the application domain
        // if a failure occurs in this code region.
        //
        Thread.EndCriticalRegion();
        //
        // Code in this region can be aborted without affecting
        // other tasks.
    }
}
using namespace System::Threading;

public ref class MyUtility
{
public:
   void PerformTask()
   {
      // Code in this region can be aborted without affecting
      // other tasks.
      //
      Thread::BeginCriticalRegion();
      //
      // The host might decide to unload the application domain
      // if a failure occurs in this code region.
      //
      Thread::EndCriticalRegion();
      //
      // Code in this region can be aborted without affecting
      // other tasks.
   }
};
import System.Threading.*;
import System.Threading.Thread;

public class MyUtility
{
    public void PerformTask()
    {
        // Code in this region can be aborted without affecting
        // other tasks.
        //
        Thread.BeginCriticalRegion();

        //
        // The host might decide to unload the application domain
        // if a failure occurs in this code region.
        //
        Thread.EndCriticalRegion();
        // Code in this region can be aborted without affecting
        // other tasks.
    } //PerformTask
} //MyUtility
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からThread.EndCriticalRegion メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からThread.EndCriticalRegion メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からThread.EndCriticalRegion メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Thread.EndCriticalRegion メソッド」の関連用語

Thread.EndCriticalRegion メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Thread.EndCriticalRegion メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS