Run method only if one of inputs is changed

unhandled

#1

Hi,

Is there a way to check in visual studio if specific input parameter is changed (let say the first input)?

The reason for asking I want to run a method only if one parameter is changed.
While when I changing lets say second or third inputs, that pseudo method is not called.

I could do with boolean values to reset something. But would like to have a bit more automatic response.


#2

Hi Petras,

I tend to save such input values in a member variable and then compare if it has changed, like so:

{
    if (InputA != m_inputA)
    {
         // OK, it has changed, do something
         DoSomething();
    }

     // save the last value for comparing the next round.
     m_inputA = InputA;
}

< additional code >

private double m_inputA;

// Rolf


#3

You have in mind a global value?

I wonder how to go around if my input is list of strings which is composed with around 1000 lines of text.

Is there any way to associate such input value with some sort identifier like guid?


#4

yes, I usually name them “m_last_inputA”, forgot the “last” bit in the name.

Perhaps you could save a hash of the text-list and save it in a similar manner, like so:

 private string m_LastInputA_AsHash;

(I don’t know if .NET has some inbuiklt function for making a hash of text data, but probably it has)

// Rolf