Using C # .NET 4.0
My company app uses a resource lock to edit records at the same time. We use the database to store the start time of the lock, as well as the user who acquired the lock. This led to the following (strange?) Implementation of utilization in the resource store, which, as it turns out, is called from the destructor:
protected virtual void Dispose(bool disposing)
{
lock (this)
{
if (lockid.HasValue)
{
this.RefreshDataButtonAction = null;
this.ReadOnlyButtonAction = null;
try
{
**Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("@lockID", lockid.Value);
parameters.Add("@readsToDelete", null);
Object returnObject = dbio2.ExecuteScalar("usp_DeleteResourceLockReads", parameters);**
lockid = null;
}
catch (Exception ex)
{
Logger.WriteError("ResourceLockingController", "DeleteResourceLocks", ex);
}
finally
{
((IDisposable)_staleResourcesForm).Dispose();
_staleResourcesForm = null;
}
}
}
}
, "Handle is not initialized" . , Finalize(), dispose()? - , Dispose()?