@@ -90,7 +90,7 @@ static SQLiteConnection()
9090 /// </remarks>
9191 public virtual SQLiteConnection Clone ( )
9292 => new ( DatabasePath , databaseOpenFlags , StoreDateTimeAsTicks , Serializer , _tableMappings , ExtraTypeMappings , Resolver , encryptionKey ) ;
93-
93+
9494 /// <summary>
9595 /// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath.
9696 /// </summary>
@@ -111,8 +111,13 @@ public virtual SQLiteConnection Clone()
111111 /// <param name="resolver">A contract resovler for resolving interfaces to concreate types during object creation</param>
112112 /// <param name="encryptionKey">When using SQL CIPHER, automatically sets the key (you won't need to override Clone() in this case)</param>
113113 /// <param name="configOption">Mode in which to open the db. Default to Serialized</param>
114+ /// <param name="busyTimeout">
115+ /// Sets a busy handler to sleep the specified amount of time when a table is locked.
116+ /// The handler will sleep multiple times until a total time of busyTimeout has accumulated.
117+ /// Default to 1s
118+ /// </param>
114119 public SQLiteConnection ( string databasePath , SQLiteOpenFlags openFlags = SQLiteOpenFlags . ReadWrite | SQLiteOpenFlags . Create , bool storeDateTimeAsTicks = true , IBlobSerializer ? serializer = null , IDictionary < string , TableMapping > ? tableMappings = null ,
115- IDictionary < Type , string > ? extraTypeMappings = null , IContractResolver ? resolver = null , string ? encryptionKey = null , ConfigOption configOption = ConfigOption . Serialized )
120+ IDictionary < Type , string > ? extraTypeMappings = null , IContractResolver ? resolver = null , string ? encryptionKey = null , ConfigOption configOption = ConfigOption . Serialized , TimeSpan ? busyTimeout = null )
116121 {
117122 if ( string . IsNullOrEmpty ( databasePath ) )
118123 throw new ArgumentException ( "Must be specified" , nameof ( databasePath ) ) ;
@@ -149,7 +154,7 @@ public SQLiteConnection(string databasePath, SQLiteOpenFlags openFlags = SQLiteO
149154 throw new Exception ( "Invalid cipher key" ) ;
150155 }
151156
152- BusyTimeout = TimeSpan . FromSeconds ( 0. 1) ;
157+ BusyTimeout = busyTimeout ?? TimeSpan . FromSeconds ( 1 ) ;
153158 Serializer = serializer ;
154159 StoreDateTimeAsTicks = storeDateTimeAsTicks ;
155160 ExtraTypeMappings = extraTypeMappings ?? new Dictionary < Type , string > ( ) ;
@@ -179,8 +184,7 @@ public TimeSpan BusyTimeout
179184 set
180185 {
181186 _busyTimeout = value ;
182- if ( Handle != null )
183- sqlite . BusyTimeout ( Handle , ( int ) _busyTimeout . TotalMilliseconds ) ;
187+ sqlite . BusyTimeout ( Handle , ( int ) _busyTimeout . TotalMilliseconds ) ;
184188 }
185189 }
186190
0 commit comments