AddHandler Issue

Hi,

i create a webthread with the correct addressof method and its working.

But how i can do the same but i need to pass more variables to the method, example

t = new webthread
addhandler t.run, addressof Mymethod(variable1, variable2…etc)

Please help

Its no posible to do that, how i can add propertie in code to the webthread

Add an EventDefinition with the extra parameters.

The signature (i.e. the method definition) must match.
Just subclass the thread and add a Run(variable1, variable2…etc) event, then AddHandler will work.

I would suggest always using WeakAddressOf with addHandler to avoid circular references.

I dont want to subclass, i want to create in code. Any example?

I do not quite understand what you want to achieve. If you create a handler method to have that method execute upon thread.run, by definition, there is no parameters to pass to Run. You will not be able to do Thread.Run(variable1,variable2,etc.).

What you can do is add your parameters either inside MyMethod, or if you need to modify them outside, add properties to a module and set them before you call Thread.run.

You could put a property on the WebPage itself, set that and then have the thread check or set the property, but it will be much more portable if you subclass WebThread and add parameters to Run or properties to the subclass.

[quote=123478:@Darwin Quinones]Hi,

i create a webthread with the correct addressof method and its working.

But how i can do the same but i need to pass more variables to the method, example

t = new webthread
addhandler t.run, addressof Mymethod(variable1, variable2…etc)

Please help[/quote]

Create one object that is the “Context”
Add whatever parameters to that and pass one of those to your method
Any time you need to add more parameters you adjust the Context object & the code that uses it but never the actual method signature

OK thanks to all. I have cleared my doubts.