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

ServerStatusValue was Obsolete what is the next version? #1403

Closed
BenLampson opened this issue May 15, 2021 · 1 comment
Closed

ServerStatusValue was Obsolete what is the next version? #1403

BenLampson opened this issue May 15, 2021 · 1 comment
Labels
question The issue contains a question. After no activity the issue might be closed.

Comments

@BenLampson
Copy link

BenLampson commented May 15, 2021

I found there has obsolete description here,

[Obsolete("No longer thread safe. Must not use.")]
ServerStatusValue Status { get; }

But what's the next version use?
Here is my code

protected override void OnServerStarted(IServerInternal server)
{
    base.OnServerStarted(server);

    // request notifications when the user identity is changed. all valid users are accepted by default.
    server.SessionManager.ImpersonateUser += new ImpersonateEventHandler(SessionManager_ImpersonateUser);

    try
    {
        // allow a faster sampling interval for CurrentTime node.
        server.Status.Variable.CurrentTime.MinimumSamplingInterval = 250;

    }
    catch
    { }

}
@BenLampson BenLampson changed the title ServerStatusValue is Obsolete what is the next version? ServerStatusValue was Obsolete what is the next version? May 17, 2021
@AlinMoldovean AlinMoldovean added the question The issue contains a question. After no activity the issue might be closed. label May 21, 2021
@AlinMoldovean
Copy link
Contributor

Hello @BenLampson ,

The ServerStatusValue Status { get; } property was marked as obsolete because it is not thread safe.
The thread safe version is ServerState CurrentState { get; set; }, but it returns only the State value.

A better version of that code should be:

            try
            {
                lock (ServerInternal.Status.Lock)
                {
                    // allow a faster sampling interval for CurrentTime node.
                    ServerInternal.Status.Variable.CurrentTime.MinimumSamplingInterval = 250;
                }
            }

AlinMoldovean added a commit to AlinMoldovean/UA-.NETStandard that referenced this issue May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue contains a question. After no activity the issue might be closed.
Projects
None yet
Development

No branches or pull requests

2 participants