Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsBusy with increment/decrement counter #28

Open
thomasgalliker opened this issue Mar 6, 2023 · 0 comments
Open

IsBusy with increment/decrement counter #28

thomasgalliker opened this issue Mar 6, 2023 · 0 comments
Assignees

Comments

@thomasgalliker
Copy link
Owner

Extend ViewModelBase IsBusy flag with increment/decrement counter.

public bool IsBusy
{
    get
    {
        var count = Interlocked.CompareExchange(ref _busyRefCount, 0, 0);
        return count > 0;
    }

    protected set
    {
        if (value)
        {
            Interlocked.Increment(ref _busyRefCount);
        }
        else
        {
            Interlocked.Decrement(ref _busyRefCount);
        }

        this.RaisePropertyChanged();
    }
}

Source:
https://github.com/epam/covid-resistance-mobile/blob/1152f1e432edc0ccca89ddad1ddb0d48c7e4f1f4/src/Covi/Features/!Base/ViewModelBase.cs

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

No branches or pull requests

1 participant