Because of your note that is prohibited to manipulate the GUI from within a thread I tried applying what they showed in the example of the thread class in the LR. I put the counter in the module and made a timer which writes it to the textfield. But surprisingly the GUI is still affected for example when you move over the buttons the cursor.
Is that still the wrong way?
My guess is that you're never actually running on a thread. As was pointed out above, subclassing Thread and adding a method with the same name as the Run event means your code is not actually executing in the thread, i.e. from the Run event.
My intention was to have a thread class to which I can pass a method instead of making a subclass everytime. If I remember it right I could do this in VB.net
You don't need to subclass Thread to accomplish this. You just need to use AddHandler: http://docs.realsoftware.com/index.php/AddHandler
Here's a snippet of code from a Window in one of my projects. Task is a Window property of type Thread, and ImportRun is a method of said Window with the following signature:
Protected Sub ImportRun(objCaller As Thread)
Self.Task = New Thread 'Note that I'm using the generic Thread class.
AddHandler Task.Run, AddressOf ImportRun 'ImportRun will be called when the thread starts.
* The handler method must have the correct parameters for whatever event is being handled.
* Inside the handler method, Self refers to the instance which owns the method (if any). The caller, in this case a Thread, is passed as a parameter. In the example above, my handler can access any properties or methods of the Window, though it still can't do something that updates the GUI.
I downloaded and modified your sample project to use AddHandler and a GUI update timer.http://webcustomcontrols.com/freeware/addhandler.zip