Re: SwingWorker appropriate
bruehlicke <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <CAHQSMeW9SA7fgYXUjn_JmgAUbE_f5eR5Ev_pA1oVjCuZyE8cTw@mail.gmail.com> |
Using SwingWorker with Netbeans Platform has been the very helpful to my code. It is just easier to use and control. I also use it to sent chunks of results to the Lookup to be consumed by different modules while running. Tricky part is to get rid of those chunks when the process is cancelled or failed without triggering too many Lookup events. So I would for sure suggest to work using the SwingWorker. On Fri, Jul 29, 2016 at 4:36 AM, Martin Entlicher < [email protected]> wrote: > Without seeing the actual code it's hard to say why something that works > with SwingWorker does not work with RequestProcessor. SwingWorker is aware > of Event Dispatch Thread, while RequestProcessor is not, that can make a > difference. > > RequestProcessor is used in the Platform internally, therefore it can be > more efficient if you use it as well. But unless you need to optimize for > the number of threads, I guess it's not a big deal if you keep using > SwingWorker. > > Regards, > Martin > > > On 28.7.2016 19:51, Mario Schroeder wrote: > >> Hi, >> >> I have the following use case: >> >> I want to start a long running task in a background thread when the user >> clicks on an 'ok' button of my dialog. When the process finishes succesful >> the result shall be populated via Lookup. >> But when the user clicks on cancel the tasks should be canceled too, and >> the result should not be populated, or if accidently populated simply >> removed. >> >> My scenario works fine with a SwingWorker. >> >> But I'm having trouble when I use the RequestProcess of NetBeans. >> >> My question: Is the SwingWorker appropriate for the Plattform, or should >> I continue to try my luck with the RequestProcessor? >> >> Regards >> > > >