Container and Thread

I built a custom control encapsulated in a container control… there will only be one instance of this control in the application
When a method in this control is called … I need a thread to execute to do some background processing

  • I added a thread control to the container
  • I put the required code in the RUN event
  • then this code in the containers method to fire it off
		Dim th As  thread1
		th=New thread1
		th.run

and I get (on BOTH the 1st two lines above)

VB is the custom control

You dropped the thread from the library to the cointainer?

yes
and if I rename the thread object, the error changes (rightfully so) to

besides… If I had not inserted the control. I could not have written the Run event :slight_smile:

If the thread is an object on the designer view of the container you don’t need to instantiate it, just InterfaceThread1.Run

If the thread is a property of the container, then you would need to instantiate it and run.

[quote=332436:@Tim Parnell]If the thread is an object on the designer view of the container you don’t need to instantiate it, just InterfaceThread1.Run

If the thread is a property of the container, then you would need to instantiate it and run.[/quote]

		//Dim th As  thread1
		//th=New thread1
		//th.run
		thread1.run

WORKS!