Thread.Run (item does not exist)

I got my program working well in Xojo. Now the problem is lag during certain processes, so I moved all my calculations to a thread. Everything is all done; I go to test and I get item does not exist concerning not the thread itself, but the RUN method of the thread class.

My thread is being called from a timer… but I wouldn’t suspect a problem, as I’ve seen it used in a timer in examples… Besides, I’ve also tried it in the open event of a window, and I get the same problem. I checked the class of the thread instance, and it says Thread. Hopefully its something small.

Any help would be great. Thanks.

is apiCalcThread a variable name of the name of the thread class?

I don’t understand your question, which makes me think you might have the answer. haha. apiCalcThread is the name of the thread instance.

Oh by the way i was in the process of moving, so i haven’t got to checkout your solution for the vb -> xojo conversion. I still would like to pay you for it, if it works, I still haven’t looked at it though.

well, to have run method working, you need to use a variable for the instance, not just class name.

I don’t see that in the docs… Is there any docs info on that ?

Is apiCalcThread a class or an instance of a class?

is that screenshot from class definition?

you have to define a variable of the class name and make a new instance.
Than you can call run method on that.

[quote=124579:@Christian Schmitz]you have to define a variable of the class name and make a new instance.
Than you can call run method on that.[/quote]

Man I’m drawing a blank kinda. Because like with shells, if i drag an empty class to the interface and set the super to shell. I don’t have to instantiate or define a variable right… why is it different with thread

I’m thinking :

[code]dim t as new thread
t = apiCalcThread[/code]

like that ? Forgive my ignorance, I’ve never had this problem… I’m lacking some understanding

You either drag a class onto a window, then you have an instance.
Or you create a property in the window, then you need to use New to get an instance.
Don’t do both, because you will have two instances in your window.

Yeah thats why I’m lost, because I dragged the class, named it , and put code in the run event.
So I should be able to call in a timer… right ?

make property in window
t as apiCalcThread

in code than

t = new apiCalcThread

Yes, but you are using AddHandler for Run. Why? Just create the Run event on the instance of your thread and put the code in there.

he made subclass, so why not use run event there?

Thanks Christian, worked great, now I have a new problem though. ha. My thread implementation is even laggier than before. I’m going to have to try that ‘task’ thread subclass implementation with the updateUI method.

Chris - what priority have you assigned to your thread? If the priority is too high, it will bog your app just as if you had not used a thread.

Priority doesn’t really matter if you have only one thread running…

Priority does matter if you have one thread in addition to the main thread. You can give more or less time to the UI to make it seem more or less responsive.