WithEvents, Events and Arrays Problem

Kesher

Member
Joined
Feb 12, 2007
Messages
6
Programming Experience
10+
Hi everyone,

Im new to this forum and am looking for an solution to a problem.

Im trying to develop an application which has an array of ClassA objects. ClassA has events so it needs to be defined like this:-

Public WithEvents ClientConnection As ConnectionClass

However, when i try to create an array using the same line, VB.net doesn't like the WithEvents keyword because you apparently can't declare an array with WithEvents:

Public WithEvents ClientConnections(10) As ConnectionClass

Additional information, each ConnectionClass has its own thread and i'd like them to be able to pass back information using events so that it operates a quickly as possible. I played with the idea of having a public field to pass data back and have a thread checking each object for returned database, but it was too slow.

Any ideas would be great? Is there any way i can create a callback function which all classes can have access to? If so, has anyone actually done it and has any sample code?

Many thanks
Dan Journo
Kesher Communications
www.TextOver.com
 
You'll need to initialize the items in the array....

VB.NET:
Some Sub
 
Dim ClntCon as ConnectionClass
 
For I as integer = 0 to ClientConnections.GetUpperbound(0)
 
ClntCon = ClientConnections(i) 
 
ClntCon = New ConnectionClass
 
AddHandler Clntcon.SomeEvent,  Addressof Some Method
 
Next
 
End Sub
 
Back
Top