I have this class setter and getter
public class CallbackObjectForJs
{
public int _flag = 3
public int loopKe
{
set { _flag = value; }
get { return _flag; }
}
}
And, I already registered this class at the top
chromeBrowser.RegisterJsObject("aobjclass", new CallbackObjectForJs())
I already succeed to call class object c# to js and return value "3"
const string script = @"(function()
{
var atemp = aobjclass.loopKe
return atemp;
})();";
chromeBrowser.EvaluateScriptAsync(script).ContinueWith(x =>
{
var response = x.Result;
if (response.Success && response.Result != null)
{
this.Invoke((MethodInvoker)delegate
{
int atemp = (int)response.Result;
MessageBox.Show(atemp.ToString()); //show value "3"
});
}
});
But, in the next process I change my _flag value
CallbackObjectForJs _classJs = new CallbackObjectForJs();
int aflag = _classJs._flag;
_classJs._loopke = aflag + 1;
In C# the value has been changed "4", but when I call again this class in cefsharp javascript. The value still not change with value "3"
Please help me to solve this problem. Thanks