blah blah blah is here! blah blah » Close

up1down
link

Guys, not sure if this can be done but this is my situation: I'am using a timer event to refresh entries from a database on a local server to populate my application, now the fefresh is every 10 mins.

If the server or connection should break i don't want a horrid default VS warning window popping up scaring people! is there a way it can ignore the fact it can't find the server and keep trying in the background? or is that way too complicated?

My timer refresh code is:

private void timer2_Tick(object sender, EventArgs e)
{

this.usedTableAdapter.Fill(this.usedDataSet.used);
usedColor();
}

last answered one year ago

1 answers

link

I don't know whether it will work but you could try something like this:

private void timer2_Tick(object sender, EventArgs e)
{
try
{
this.usedTableAdapter.Fill(this.usedDataSet.used);
usedColor();
if (timer2.Interval == 60000) timer2.Interval *= 10;
}
catch
{
MessageBox.Show("Refresh was unsuccessful. Will try again in 1 minute");
if (timer2.Interval == 600000) timer2.Interval /= 10;
}
}

That works great vuples, I thought i was going to have to ping the server or do something far more complicated. Your solution is just what i'm looking for. Thanks.

Feedback