Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2010 Best way for two routines to use the same array/list

$
0
0
Good Morning Everyone,

I am struggling to figure out the best way to allow two separate routines access the same array/list.

I will be having a routine that will simply add to the array/list and another routine that reads and deletes each item as it reads it. Now I know you cannot have two things using a list at the same time but here is an example of what I am needing:

Code:

Dim MyList as List (of String)

Private Sub tmrAdd_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    MyList.Add("a random string")
End Sub

Private Sub tmrRead_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    dim myvar as string

    For each item in MyList
          myvar = MyList(item)
          MyList.Remove(item)
    Next

End Sub

Note the above is just a rough idea that I quickly typed for an idea of what I want and I know isn't correct :-)

Viewing all articles
Browse latest Browse all 42215

Trending Articles