0
I’m using Cefsharp and I wanted when clicked on the button runs the javascript
every 1 second and in the background too, and only stop if you hit the off button. I tried for the backgroundworker but I couldn’t, I’m kind of layy in this part:
When you click the button runs the background worker:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
bool rodando = true;
chromeBrowser.ExecuteScriptAsync("$(document).ready(function(){if($('#signup_button').is(':visible')){alert('Você precisa estar logado para utilizar o script')}})");
try
{
Thread t = new Thread(() =>
{
while (rodando)
{
Thread.Sleep(1000);
Script();
}
});
t.Start();
}
catch
{
}
}
Shutdown:
private void btnscriptshutdown_Click(object sender, EventArgs e)
{
if (worker.WorkerSupportsCancellation)
worker.CancelAsync();
}
Only it’s not looping, it only runs once, as I can always run?
Still having trouble with that code?
– perozzo
Yeah just what I’m doing by the button now, without the background worker
– user92401
You could try through a Timer..
– perozzo
How would you look to run until you hit a stop button?
– user92401
I’ll put the code, give me a break.
– perozzo