Save the items of a ListBox every 1 minute

  • Thread starter Thread starter Drunkalot
  • Start date Start date
D

Drunkalot

I wrote a program that made some combinations and add them to a listbox, and
i need to save the contents of the listbox every 1 minute...

The method that save the content of the listbox i have already wrote, but
i´m having problems making a timer to save that...

Do you all have an idea how i can do this??
 
You can create a timer that executes every 60000 (interval) milliseconds.
In the tick event, you can call your save method.
HTH
JB
 
Drunkalot said:
I wrote a program that made some combinations and add them to a listbox, and
i need to save the contents of the listbox every 1 minute...

The method that save the content of the listbox i have already wrote, but
i´m having problems making a timer to save that...

Hi Drunkalot,

does the Windows.Forms.Timer fit your needs?

private System.Windows.Forms.Timer timer1;

[...]

this.timer1.Interval = 60 * 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);

[...]

private void timer1_Tick(object sender, System.EventArgs e)
{
SaveMyListBox();
}

System.Threading.Timer would be another possibility, perhaps better if
your timer has to tick *exactly* every 60 seconds. The
Windows.Forms-Timer is part of the UI-Message-Queue and may not tick if
your UI is blocked for any reason.

http://msdn.microsoft.com/library/?.../html/frlrfsystemthreadingtimerclasstopic.asp

Cheers

Arne Janning
 
Back
Top