Private TCPSocket Thread Access?

I have a sub classed TCPSocket that I use with all private properties and methods to ensure each data set of each connection to my app is unique. I need to call a thread from within one of the private methods in my TCPSocket class which then calls another private method in my TCPSocket class to populate a private string property also in my TCPSocket class. How can I create a thread that I can use from within my TCPSocket class that can access my private methods and properties of my TCPSocket class? Is this possible? Thanks.

Yes. Add a myThread as Thread property to your class. In Open do myThread = New Thread and addhandler Run to a method.

Then to start the thread go myThread.Run as always.

Looks like I might learn something new today after all. :slight_smile:

So I get myThread as Thread, already did that. I get myThread = New Thread in Open, not a problem. Here is where I’m a bit lost. Usually I just add a thread to my project or a sub classed thread in this one because it’s a console app. At that point I would just add an event handler for run and add my code in there. So the addhandler Run to a method part I’m unfamiliar with. How exactly do I accomplish this part in my TCPSocket class? Thanks!

[code]myThread = New Thread

AddHandler myThread.Run, AddressOf myThread_Run[/code]

Create a method called myThread_Run with parameter Sender as Thread

That method will be the Run event handler.

Wow. That’s probably something very basic I should know already but don’t. I imagine you could handle almost any event handler in this way. Much appreciated! :slight_smile:

You’re welcome.

This is the secret to use objects such as threads and timers within a subclass, as you cannot drag the control onto it. And yes, you can implement any event.

You may want to read