New topic: Add an instance of the LongProcessThread class
<http://forums.realsoftware.com/viewtopic.php?t=33750> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message metron9 Post subject: Add an instance of the LongProcessThread classPosted: Wed May 12, 2010 12:05 am Joined: Mon May 10, 2010 9:26 pm Posts: 6 Working through some of the Classes I am trying the example in the Language Reference for THREAD Following the example I added a new class to the Project but how do I add an instance for the new class to the window? I tried it another way by adding the THREAD icon from the built in controls and put the code inside that and the sample code runs and works fine. Just curious how I would add an instance if i did it the way the example shows and is there any reason to do it one way or the other? Second question. I set the priority of the thread at 1 (lowest) and then created a timer that would increment a variable by 1 each second. When i execute the code, the timer stops unless I do some scrolling of the listbox the thread code is filling. This is for me threading a needle with a sludge hammer since iI am use to working in time slices in the millionths of a second in assembler and hardware interrupts. Is there a good primer on event timing and threads, I would imagine for games you must use something else as the Thread Scheduler I would think would not do the job. Top timhare Post subject: Re: Add an instance of the LongProcessThread classPosted: Wed May 12, 2010 12:45 am Joined: Fri Jan 06, 2006 3:21 pm Posts: 7723 Location: Portland, OR USA Drag a Thread onto the window and change its Super to LongProcessThread. Or click the drop-down above the list of objects and select Project Controls. Your class will show there. RB threads are cooperative, not preemptive, so forget everything you know about interrupts. You have to yield time periodically. RB is able to yield at loop boundaries, but it doesn't do so unless it thinks it needs to. In later releases, they have leaned toward throughput and so they yield less frequently. So you really have to do the yielding yourself and tune the frequency to your needs - speed vs. responsiveness. Top metron9 Post subject: Re: Add an instance of the LongProcessThread classPosted: Wed May 12, 2010 8:35 am Joined: Mon May 10, 2010 9:26 pm Posts: 6 I can add a class under the Project tab make Super=Thread and put code into it. When i drag the Built in control and change the name to match that class it works. If i use the drop down box and drag the class icon to the main window, it does not work, Property does not exist error. So I will use the method that does work. Are there yielding commands one can use in a thread that has a long process like keep a counter and yield after so many iterations? Or, would you not use a thread in this way. Is there a system timer or way to know the code execution time in units or cycles? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
