Skip to content

Incorrect .NET Code for Distributed Lock #2937

@halspang

Description

@halspang

Describe the issue
The code listed for the Distributed Lock building block example doesn't compile.

URL of the docs
How-To: Use a lock

Expected content

class Program
{
    [Obsolete("Distributed Lock API is in Alpha, this can be removed once it is stable.")]
    static async Task Main(string[] args)
    {
        string DAPR_LOCK_NAME = "lockstore";
        string fileName = "my_file_name";
        var client = new DaprClientBuilder().Build();

        await using (var fileLock = await client.Lock(DAPR_LOCK_NAME, fileName, "random_id_abc123", 60))
        {
            if (fileLock.Success)
            {
                Console.WriteLine("Success");
            }
            else
            {
                Console.WriteLine($"Failed to lock {fileName}.");
            }
        }
    }
}

Additional context
Found by a discord user (Adam R).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions