Visual Basic (Declaration) | |
---|---|
Sub ReleaseLock() |
C# | |
---|---|
void ReleaseLock() |
Demonstrate using a workbook set in a thread safe manner.
C# | Copy Code |
---|---|
void DoSomeThreadSafeWork(IWorkbookSet workbookSet) { // Interrupt background calculation if necessary and acquire an // exclusive lock on the workbook set. workbookSet.GetLock(); try { // Do some work... } finally { // Release the lock on the workbook set and start background // calculation if appropriate. workbookSet.ReleaseLock(); } } |
Visual Basic | Copy Code |
---|---|
Sub DoSomeThreadSafeWork(ByVal workbookSet As IWorkbookSet) ' Interrupt background calculation if necessary and acquire an ' exclusive lock on the workbook set. workbookSet.GetLock() Try ' Do some work... Finally ' Release the lock on the workbook set and start background ' calculation if appropriate. workbookSet.ReleaseLock() End Try End Sub 'DoSomeThreadSafeWork |
This method is thread safe.
Calls to GetLock may be nested. SpreadsheetGear.IWorkbookSet.ReleaseLock must be called once for each call to GetLock.
Interruptible background calculation will be started if the following conditions are all met:
- The last lock acquired by the current thread is being released.
- There are no other threads waiting to acquire a lock on this workbook set.
- BackgroundCalculation is set to true.
- Calculation is not set to Calculation.Manual.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family