|
using System;
using System.Threading;
using System.Reflection;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BrainTechLLC.ThreadSafeObjects;
namespace BrainTechLLC.DAL
{
public class PerformOnce
{
public bool _performed;
private Lockable _lock;
public bool CheckPerformOnce(DALVoidDelegate performIfTrue)
{
bool performed = false;
if (!_performed)
{
Interlocked.CompareExchange<Lockable>(ref _lock, new Lockable(), null);
_lock.AquireLock();
try
{
if (!_performed)
{
performIfTrue();
_performed = true;
performed = true;
}
}
finally
{
_lock.ReleaseLock();
}
}
return performed;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Currently working as a Senior Silverlight Developer with Troppus Software in Superior, CO. I enjoy statistics, programming, new technology, playing the cello, and reading codeproject articles.