SqlCeLockTimeoutException Class

This exception is thrown if the lock timeout has been reached.

Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Syntax

'Declaration
Public Class SqlCeLockTimeoutException
    Inherits SqlCeException
public class SqlCeLockTimeoutException : SqlCeException
public ref class SqlCeLockTimeoutException : public SqlCeException
public class SqlCeLockTimeoutException extends SqlCeException
public class SqlCeLockTimeoutException extends SqlCeException

Remarks

For more information, see the topic "Locking (SQL Server Compact 3.5 SP1)" in the SQL Server Compact 3.5 SP1 Books Online.

Inheritance Hierarchy

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

Example

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);
    }
}

Thread Safety

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.

Platforms

Development Platforms

Windows Vista, Windows Mobile 5.0, Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Mobile 2003 for Pocket PC, Windows CE 5.0
Version Information
.NET Framework and NET Compact Framework
Supported in 3.5
.NET Framework
Supported in 3.0
.NET Compact Framework and .Net Framework
Supported in 2.0

See Also

Reference

SqlCeLockTimeoutException Members
System.Data.SqlServerCe Namespace