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
IStepper Enabled property does not work as described. #768
Comments
Looking at the SK.cs Step method, I don't see any checks of the Enabled property. I set up a small test case.
In this test Enabled is in fact false. With a breakpoint set on the statement in the Step() method, the debugger does stop there indicating that Step() method was called even when Enabled is false. |
@maluoi Did you see this? Any comments on what to do with the Enabled flag. There must be some reason you did not allow the Enabled flag to be changed. I can't think of a use case where I create an object only to set it to not Enabled. Since there is no setter on the property it can't be set outside private code in the class. How did you intend for us to use this property? |
I have been thinking about this a bit lately. It's not currently used but I don't remember why, and it probably should be especially considering what the docs say. It's been a while since I wrote that! However, here's how you should use it: public class TestStepper : IStepper
{
// If you just want it to always step
public bool Enabled => true;
// If you want to control stepping
public bool Enabled { get; set; } = true;
// The way it probably should work
public void Step() {}
// How you can do it properly today
public void Step() {
if (!Enabled) return;
}
public bool Initialize() => true;
public void Shutdown () {}
} I suppose it's good to note explicitly here that the |
@maluoi I'm using it in today's current mode as you have in the response above. I am integrating Teams into my application and there are parts of Teams that need to be "on" all the time and the rest needs to be off when not in a call. I am using the whole concept of your Step() as a driving model in my designs for industrial applications. These are highly dynamic so anywhere I can save a CPU/GPU cycle or two is helpful. |
@maluoi Here is what I am currently doing. I have an interface, ImyInterface : IStepper. In ImyInterface I added a "new bool Enabled {get; set;}" definition to overrule the IStepper's Enabled property. Then I added a bunch of other properties and other method templates for ImyInterface as needed by my code. The million-dollar question: Does this really affect the StereoKitC code? I cannot find any definition in it where Enabled is used as a value that is evaluated by the C++? I think you answered it already, that it is not currently implemented, but just double-triple checking. C# hiding or overruling an interface in a concrete class must in the end be properly extended to the NativeAPI calls.
|
The Your |
For anyone encountering this thread. Currently (0.3.8) you must manage the Enabled property, which is simple but nice to know. The other two issue topics are also answered, if you wish to see them. |
Description
According to the documentation if class derived from IStepper has its Enabled property set to false the Step method on that class is not called (assuming thereby, time is saved or other state evaluations may be avoided in not checking anything in the Step method.
I subclassed IStepper into an abstract class that overrides the Enabled property giving it a setter which really just hides the IStepper Enabled property. Currently the IStepper class does not provide a setter and no method to set the Enabled property bool state.
Since there is no way to change the state of the Enabled property even in an override the Step method continues to be called. What is the recommended way of setting the Enabled property?
Platform / Environment
Windows 11 latest production build, VS2022 latest updates, StereoKit 0.3.8
Logs or exception details
The text was updated successfully, but these errors were encountered: