ConnectivityStatus.IsOffline Özellik

Tanım

Bir uygulamanın çevrimdışı modda olup olmadığını belirten bir değer alır veya ayarlar.

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

Özellik Değeri

true uygulama çevrimdışı moddaysa; aksi takdirde , false.

Örnekler

Aşağıdaki örnek kod, bir onay kutusu değerine bağlı olarak çevrimdışı durumu güncelleştirmek için bu özelliğin nasıl kullanılacağını gösterir. Bu örnekte, bir CheckedChanged olay işleyicisi çevrimdışı durumu güncelleştirir. Kullanıcı uygulamayı çevrimiçi duruma ayarlarsa, olay işleyicisi kullanıcıyı yeniden doğrulamayı dener. Ancak, kimlik doğrulama sunucusu kullanılamıyorsa, olay işleyicisi uygulamayı çevrimdışı duruma döndürür.

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

Açıklamalar

özelliğini ayarladığınızda IsOfflineConnectivityStatus , sınıfı değeri yerel dosya sisteminde önbelleğe alır. Ad alanı içindeki System.Web.ClientServices.Providers istemci hizmeti sağlayıcıları, ilişkili Microsoft Ajax kimlik doğrulaması, rolleri ve profil hizmetlerine erişmeye çalışmak yerine çevrimdışı veri önbelleğinin kullanılıp kullanılmayacağını belirlemek için bu değeri denetler.

Şunlara uygulanır

Ayrıca bkz.