Partager via


Classe SqlCeLockTimeoutException

Cette exception est levée si le délai d'attente des verrous est atteint.

Espace de noms :  System.Data.SqlServerCe
Assembly :  System.Data.SqlServerCe (dans System.Data.SqlServerCe.dll)

Syntaxe

'Déclaration
Public Class SqlCeLockTimeoutException _
    Inherits SqlCeException
'Utilisation
Dim instance As SqlCeLockTimeoutException
public class SqlCeLockTimeoutException : SqlCeException
public ref class SqlCeLockTimeoutException : public SqlCeException
type SqlCeLockTimeoutException =  
    class
        inherit SqlCeException
    end
public class SqlCeLockTimeoutException extends SqlCeException

Notes

Pour plus d'informations, consultez la rubrique « Verrouillage (SQL Server Compact 3.5) » de la documentation en ligne de SQL Server Compact 3.5.

Exemples

        Dim timeout As New TimeSpan(0, 0, 15) 'hours, minutes, seconds
        Dim startTime As DateTime = DateTime.Now

        While DateTime.Now - startTime < timeout
            Try
                Dim repl As New SqlCeReplication()

                repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll"
                repl.Publisher = "myPublisher"
                repl.PublisherDatabase = "AdventureWorks"
                repl.PublisherSecurityMode = SecurityType.NTAuthentication
                repl.Publication = "AdventureWorks"
                repl.Subscriber = "Test"
                repl.SubscriberConnectionString = "Data Source='MyDatabase.sdf';Password='';"
                repl.Synchronize()
            Catch exInProgress As SqlCeTransactionInProgressException
                Thread.Sleep(3000)
                GoTo ContinueWhile1
            Catch exTimeout As SqlCeLockTimeoutException
                ' Add your own error-handling logic here
                 GoTo ContinueWhile1
            Catch e As SqlCeException
                MessageBox.Show(e.Message)
            End Try
        ContinueWhile1:
        End While
        TimeSpan timeout = new TimeSpan(0 /*hours*/, 0 /* minutes */ , 15 /*seconds*/);
        DateTime startTime = DateTime.Now;

        while (DateTime.Now - startTime < timeout)
        {
            try
            {
                SqlCeReplication repl = new SqlCeReplication();

                repl.InternetUrl = "https://www.adventure-works.com/sqlmobile/sqlcesa35.dll";
                repl.Publisher = "myPublisher";
                repl.PublisherDatabase = "AdventureWorks";
                repl.PublisherSecurityMode = SecurityType.NTAuthentication;
                repl.Publication = "AdventureWorks";
                repl.Subscriber = "Test";
                repl.SubscriberConnectionString = "Data Source='MyDatabase.sdf';Password='';";
                repl.Synchronize();
            }
            catch (SqlCeTransactionInProgressException)
            {
                Thread.Sleep(3000);
                continue;
            }
            catch (SqlCeLockTimeoutException)
            {
                //add your own error-handling logic here
            }
            catch (SqlCeException e)
            {
                MessageBox.Show(e.Message);
            }
        }

Hiérarchie d'héritage

System. . :: . .Object
  System. . :: . .Exception
    System. . :: . .SystemException
      System.Data.SqlServerCe. . :: . .SqlCeException
        System.Data.SqlServerCe..::..SqlCeLockTimeoutException

Sécurité des threads

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Voir aussi

Référence

Membres SqlCeLockTimeoutException

Espace de noms System.Data.SqlServerCe