I'm using the Timer control and I want set the interval equal to the Proc_BurstTime of an object in a ListBox. I can't figure out how I can go about this.
The thing is, I have multiple things different objects in the ListBox; what I want to do is have the program go through the Proc_BurstTime of each object in the list.
So for example, I have a ProgressBar. There are 5 things in the ListBox with these Proc_BurstTime values (in ms): 5000 4000 1000 7000 2000 The program should go to the first object in the ListBox, set the progress bar to "load" for X seconds (Proc_BurstTime). The first one will be 5000 ms (5 seconds), the progress bar will go from 0 to 100 in 5 seconds, once completed, it will go to the next one, 4000 ms; so on so forth.
My issue is this:
timer1.Interval = initial_ProcessList.Items[0].Proc_BurstTime;
This is the error I get
*'object' does not contain a definition for 'Proc_BurstTime' and no extension method 'Proc_BurstTime' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)*
This is my structure and initialization:
struct process
{
public int Proc_Id;
public int Proc_BurstTime;
public int Proc_Priority;
public override string ToString()
{
return "ID: " + Proc_Id.ToString() + " Time: " + Proc_BurstTime.ToString() + " Prior: " + Proc_Priority.ToString();
}
};
readonly process[] ProcessList = new process[]
{
new process{ Proc_Id = 1, Proc_BurstTime = 5000, Proc_Priority = 1},
new process{ Proc_Id = 2, Proc_BurstTime = 4000, Proc_Priority = 2},
new process{ Proc_Id = 3, Proc_BurstTime = 1000, Proc_Priority = 3},
new process{ Proc_Id = 4, Proc_BurstTime = 7000, Proc_Priority = 4},
new process{ Proc_Id = 5, Proc_BurstTime = 2000, Proc_Priority = 5}
};
And this is how I am adding things to the ListBox:
private void Form1_Load(object sender, EventArgs e)
{
foreach (var p in ProcessList)
{
initial_ProcessList.Items.Add(p);
}
}