Ok, I'm trying my luck with the TaskSequence class. I'm running into another problem though... After I've added my tasks, I get a problem with this line of code:
ts.execute(ta); ts is an instance of TaskSequence ta is an instance of TaskAdapter<String> I get this error compilation error in eclipse: "The method execute(TaskListener<Void>) in the type Task<Void> is not applicable for the arguments (TaskAdapter<String>)" I know this has something to do with the Void type, where there should be String but I dont know what is causing this Regards 2010/2/24 Greg Brown <[email protected]> > You may find the TaskGroup or TaskSequence classes helpful. They allow you > to coordinate multiple running tasks. TaskGroup runs multiple tasks in > parallel, and TaskSequence runs them in series. > > On Feb 24, 2010, at 8:31 AM, Mathias Versichele wrote: > > I'm parsing files in a directory. Logically speaking, it's a task > consisting of synchronized subtasks but I thought that would make it even > more complex for me :-) > > 2010/2/24 Greg Brown <[email protected]> > >> Tasks are a great way to run a background process. I am wondering why are >> you creating and starting them in a loop? Are you trying to execute more >> than one? >> >> On Feb 24, 2010, at 8:19 AM, Mathias Versichele wrote: >> >> > Ok, this might be the most difficult question until now from me >> (especially since I can't seem to fully understand synchronization). I'm >> using a Task class to run a background task asynchronously, so that the UI >> stays responsive and my activityMeter keeps me informed about the progress >> of the task. The problem now is, that somewhere I do this: >> > >> > private Process process; >> > >> > ... >> > >> > for loop { >> > >> > process = new Process(...) >> > process.execute(new TaskAdapter<String>(tl)); >> > >> > other code... >> > } >> > >> > the Process class extends the Task class. If my for loop gets called >> only once everything works perfect. Otherwise, though, the code keeps >> running and the process variable gets re-initialized with every loop until >> finally only the last run of the loop makes the process run completely (with >> my UI acting accordingly). What do I have to do to make the code stop after >> the process.execute() line ? I already tried the wait and notify methods, >> but they gave me errors until I used the synchronized keyword. Then, >> however, the processes run correctly but my UI freezes (indefinitely). >> > >> > I'm kind of stuck here... is using the Task class the right way to go or >> are there better ways for running threads in the background keeping my UI >> nice and healthy ? >> > >> > Regards >> > >> > -- >> > Mathias Versichele >> > Bio-ir milieutechnologie / Msc. geografie >> > Oudburgstraat 16 >> > 9240 Zele >> > 0485/16.07.08 >> >> > > > -- > Mathias Versichele > Bio-ir milieutechnologie / Msc. geografie > Oudburgstraat 16 > 9240 Zele > 0485/16.07.08 > > > -- Mathias Versichele Bio-ir milieutechnologie / Msc. geografie Oudburgstraat 16 9240 Zele 0485/16.07.08
