ConnectivityStatus.IsOffline プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
アプリケーションがオフライン モードかどうかを示す値を取得または設定します。
public:
static property bool IsOffline { bool get(); void set(bool value); };
public static bool IsOffline { get; set; }
static member IsOffline : bool with get, set
Public Shared Property IsOffline As Boolean
プロパティ値
アプリケーションがオフライン モードである場合は true
。それ以外の場合は false
。
例
次のコード例では、このプロパティを使用して、チェック ボックスの値に応じてオフライン状態を更新する方法を示します。 この例では、イベント ハンドラーによって CheckedChanged オフライン状態が更新されます。 ユーザーがアプリケーションをオンライン状態に設定すると、イベント ハンドラーはユーザーの再検証を試みます。 ただし、認証サーバーが使用できない場合、イベント ハンドラーはアプリケーションをオフライン状態に戻します。
private void workOfflineCheckBox_CheckedChanged(
object sender, EventArgs e)
{
ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked;
if (!ConnectivityStatus.IsOffline)
{
try
{
// Silently re-validate the user.
((ClientFormsIdentity)
System.Threading.Thread.CurrentPrincipal.Identity)
.RevalidateUser();
// If any settings have been changed locally, save the new
// new values to the Web settings service.
SaveSettings();
// If any settings have not been changed locally, check
// the Web settings service for updates.
Properties.Settings.Default.Reload();
}
catch (System.Net.WebException)
{
MessageBox.Show(
"Unable to access the authentication service. " +
Environment.NewLine + "Staying in offline mode.",
"Warning", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
workOfflineCheckBox.Checked = true;
}
}
}
Private Sub workOfflineCheckBox_CheckedChanged( _
ByVal sender As Object, ByVal e As EventArgs) _
Handles workOfflineCheckBox.CheckedChanged
ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked
If Not ConnectivityStatus.IsOffline Then
Try
' Silently re-validate the user.
CType(System.Threading.Thread.CurrentPrincipal.Identity, _
ClientFormsIdentity).RevalidateUser()
' If any settings have been changed locally, save the new
' new values to the Web settings service.
SaveSettings()
' If any settings have not been changed locally, check
' the Web settings service for updates.
My.Settings.Reload()
Catch ex As System.Net.WebException
MessageBox.Show( _
"Unable to access the authentication service. " & _
Environment.NewLine + "Staying in offline mode.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
workOfflineCheckBox.Checked = True
End Try
End If
End Sub
注釈
プロパティを IsOffline 設定すると、クラスは ConnectivityStatus 値をローカル ファイル システムにキャッシュします。 名前空間の System.Web.ClientServices.Providers クライアント サービス プロバイダーは、この値をチェックして、関連付けられている Microsoft Ajax 認証、ロール、およびプロファイル サービスにアクセスするのではなく、オフライン データ キャッシュを使用するかどうかを判断します。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示