SqlCeLockTimeoutException 类

如果已经达到锁定超时,则会引发此异常。

命名空间: System.Data.SqlServerCe
程序集: System.Data.SqlServerCe(在 system.data.sqlserverce.dll 中)

语法

声明
Public Class SqlCeLockTimeoutException
    Inherits SqlCeException
用法
Dim instance As SqlCeLockTimeoutException
public class SqlCeLockTimeoutException : SqlCeException
public ref class SqlCeLockTimeoutException : public SqlCeException
public class SqlCeLockTimeoutException extends SqlCeException
public class SqlCeLockTimeoutException extends SqlCeException
不适用。

备注

有关更多信息,请参见 SQL Server Compact Edition Books Online(《SQL Server Compact Edition 联机丛书》)中的“Locking (SQL Server Compact Edition)”(锁定 (SQL Server Compact Edition))主题。

示例

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/sqlcesa30.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/sqlcesa30.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);
    }
}

继承层次结构

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

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

版本信息

.NET Framework

受以下版本支持:3.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

SqlCeLockTimeoutException 成员
System.Data.SqlServerCe 命名空间