Sunday, June 2, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  12] [ 5]  / answers: 1 / hits: 7196  / 11 Years ago, mon, february 10, 2014, 12:00:00

I'm beginning to mess with CefSharp, but unsure if the behavior I am seeing is avoidable. I am attempting to execute rapid fire JavaScript statement to simulate animations to see if the refresh rate will be good enough for the project use. I've got a grid of some squares, and I would expect that I would see the colors changing rapidly, but all of the changes happen after the loop has finished, with just one refresh instead of many.



    public void start()
{
Random random = new Random();

int x = 0;
while (x < 5000)
{
string num = random.Next(16).ToString();
var script = String.Format(document.getElementById({0}).style.backgroundColor = colors[Math.floor(Math.random() * (2 - 0 + 1)) + 0];, num);
ExecuteJavaScript(script);
//MessageBox.Show();
x++;
}
}

private void ExecuteJavaScript(string script)
{
this.webView.ExecuteScript(script);
}


What is going on with ExecuteScript that it is waiting for operations to complete before refreshing?



Thanks in advance for any help!


More From » c#

 Answers
4

I've managed to get the desired results by creating a global JavaScript function, and calling the function from ExecuteScript() and in the global JavaScript function, calling start() for a constant loop.


[#47863] Monday, February 10, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byrondonavanc

Total Points: 675
Total Questions: 107
Total Answers: 105

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;