Skip to content

Add simple interface#2

Open
CumpsD wants to merge 3 commits into
aliostad:masterfrom
CumpsD:add-timer
Open

Add simple interface#2
CumpsD wants to merge 3 commits into
aliostad:masterfrom
CumpsD:add-timer

Conversation

@CumpsD
Copy link
Copy Markdown

@CumpsD CumpsD commented Dec 17, 2019

Not sure if this is something you would be interested in, a simple usage to run only one instance of an app

No offence if you dont think this PR should make it into master, it's something we needed :)

Usage:

    public class Example
    {
        public void Main()
        {
            var distributedLock = new DistributedLock<Example>(new DistributedLockOptions
            {
                Region = RegionEndpoint.EUWest1,
                LeasePeriod = TimeSpan.FromMinutes(5),
                ThrowOnFailedRenew = true,
                TerminateApplicationOnFailedRenew = true
            });

            if (!distributedLock.AcquireLock())
            {
                Console.WriteLine("Could not get lock, another instance is busy");
                return;
            }

            // Do stuff

            distributedLock.ReleaseLock();
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant