D
Dmitry Shaporenkov
Hi all,
in my application I want to implement a progress
indicator which has 'Cancel' button allowing to interrupt
the current activity. What is the best way to do such a
thing? I'm considering the following variant:
The progress indicator is created on demand on the
separate thread and stored in the local memory of the
thread that has initiated its creation ('initiating
thread'). The progress indicator also stores a reference
to the initiating thread. When a user clicks 'Cancel'
button, a delegate is executed on the initiating thread
that throws an exception, so that it can be handled
somewhere on the initiating thread.
The purpose of creating progress indicator on a separate
thread is that it will be unable to handle windows
messages (like clicking 'Cancel') if it is created on the
initiating thread.
Am I right or I'm reinventing the wheel and there is an
easier way? I would prefer simpler design, but I'm not
competent enough in WinForms to figure it out.
Thanks in advance,
Dmitry
in my application I want to implement a progress
indicator which has 'Cancel' button allowing to interrupt
the current activity. What is the best way to do such a
thing? I'm considering the following variant:
The progress indicator is created on demand on the
separate thread and stored in the local memory of the
thread that has initiated its creation ('initiating
thread'). The progress indicator also stores a reference
to the initiating thread. When a user clicks 'Cancel'
button, a delegate is executed on the initiating thread
that throws an exception, so that it can be handled
somewhere on the initiating thread.
The purpose of creating progress indicator on a separate
thread is that it will be unable to handle windows
messages (like clicking 'Cancel') if it is created on the
initiating thread.
Am I right or I'm reinventing the wheel and there is an
easier way? I would prefer simpler design, but I'm not
competent enough in WinForms to figure it out.
Thanks in advance,
Dmitry