@@ -90,7 +90,7 @@ static SQLiteConnection()
90
90
/// </remarks>
91
91
public virtual SQLiteConnection Clone ( )
92
92
=> new ( DatabasePath , databaseOpenFlags , StoreDateTimeAsTicks , Serializer , _tableMappings , ExtraTypeMappings , Resolver , encryptionKey ) ;
93
-
93
+
94
94
/// <summary>
95
95
/// Constructs a new SQLiteConnection and opens a SQLite database specified by databasePath.
96
96
/// </summary>
@@ -111,8 +111,13 @@ public virtual SQLiteConnection Clone()
111
111
/// <param name="resolver">A contract resovler for resolving interfaces to concreate types during object creation</param>
112
112
/// <param name="encryptionKey">When using SQL CIPHER, automatically sets the key (you won't need to override Clone() in this case)</param>
113
113
/// <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>
114
119
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 )
116
121
{
117
122
if ( string . IsNullOrEmpty ( databasePath ) )
118
123
throw new ArgumentException ( "Must be specified" , nameof ( databasePath ) ) ;
@@ -149,7 +154,7 @@ public SQLiteConnection(string databasePath, SQLiteOpenFlags openFlags = SQLiteO
149
154
throw new Exception ( "Invalid cipher key" ) ;
150
155
}
151
156
152
- BusyTimeout = TimeSpan . FromSeconds ( 0. 1) ;
157
+ BusyTimeout = busyTimeout ?? TimeSpan . FromSeconds ( 1 ) ;
153
158
Serializer = serializer ;
154
159
StoreDateTimeAsTicks = storeDateTimeAsTicks ;
155
160
ExtraTypeMappings = extraTypeMappings ?? new Dictionary < Type , string > ( ) ;
@@ -179,8 +184,7 @@ public TimeSpan BusyTimeout
179
184
set
180
185
{
181
186
_busyTimeout = value ;
182
- if ( Handle != null )
183
- sqlite . BusyTimeout ( Handle , ( int ) _busyTimeout . TotalMilliseconds ) ;
187
+ sqlite . BusyTimeout ( Handle , ( int ) _busyTimeout . TotalMilliseconds ) ;
184
188
}
185
189
}
186
190
0 commit comments