Need Synchronizating Data Help

Joined
Feb 2, 2008
Messages
8
Programming Experience
5-10
I'm a vb6 programmer, i know it took me a long time to hop to .net but i finally did it. I'm having a problem now with synchronizing data between multiple "threads". I used to just run multiple instances of timers and controls, and align them with public types.. I.E.

s(index).Name = "Alfred Hitchcock"
s(index).Genre = "Movies"

Each "thread" had it's own variable set and it ran nicely together because of control indexes.. I heard they turned control indexes into controlcontainers.. I'm trying to find the best way to convert this to Vb.net..

If i use controlcontainers what's the best way to synchronize the data between them? I hope this isn't too confusing.. Thanks.
Edit/Delete Message
 
I'm afraid it is too confusing. There's no such thing as a ControlContainer. Control arrays do not exist as they did in VB6 because the VB.NET event handling mechanism makes it unnecessary. If you want an array of controls then you simply create an array of controls in code, exactly the same way as you would create any other array.

That said, I don't see how any of that has anything to do with multi-threading. You should not, and by default you cannot, access control members on any thread other than the one on which they were created. If you want to access a control member from a different thread then you need to use delegation to marshal the call to the thread that owns the control's handle. In simpler terms that means you call a method on the background thread, it creates a delegate object that crosses the thread boundary and then calls the same method again, which can then safely access the control.

I've posted a fuller explanation and some example code here.
 
Ok.. So basically this is my situation..

I used to run an uptime checker off my computer that would check domains every 10 minutes on multiple winsock controls..

I'd load up an array of 50 winsock controls, 50 timer controls; one for every site..

and I'd ping them to check for uptime.. The reason i liked having 50 controls, is because if one site was down.. It wouldn't freeze up the others from checking.. I had 2 servers worth of sites that I was checking. Some were slower than others..

Then, I had a Type array. The type array stored all the data about the personal sites.. CurrentUpTime,LastChecked,Title,Url,ServerIP,DomainIP.. Etc.

I could run winsock (index: 0) and monitor the timeouts through timer control (index: 0).. The data to choose which site to check was stored in the type array 'Information' (idnex: 0)..

Everything ran solid.. But now, threading is more commonly used.. I just want to know which is the best practice to get it back to that setup.. With the new vb.net handling of things..

Make more sense?
 
In VB.Net you would use the Ping class, it has asynchronous SendAsync method. Create one Ping instance for each site. Configure timeout in PingOptions. Check result in PingCompleted event. There is only need for one Timer. Check this thread also.
 
Back
Top