tfsln
asked on
BackgroundWorker.WorkerSupportsCancellation Property
This is a question of curiosity.
Why does this propery exist? Why not just always support cancellation? It seems like a pointless property.
Kind of like having to mark classes as serializable... why cant they just be that way by default and remove the need to worry about these properties?
Why does this propery exist? Why not just always support cancellation? It seems like a pointless property.
Kind of like having to mark classes as serializable... why cant they just be that way by default and remove the need to worry about these properties?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am not sure of the exact reason but one of the reason I can think of is when you create a custom control and distribute it for others to use it and you donot want the users to cancel a running process in your control which might have an impact on your control. You can in this case set the WorkerSupportsCancellation property to false when you distribute your control and make sure the users do not make use of reflection to do something nasty to your control. This is more to do with the flexibility the programming model provides.
ASKER
Just seems to me that if you didn't want to allow cancellation, you would write your code in such a way that it doesn't attempt to cancel. It would be extremely poor practice to rely on such properties.
Strange thing really... Maybe not really the right kind of question for this site
Strange thing really... Maybe not really the right kind of question for this site
It is more flexible way to control the logic, if the tool want the user to cancel the background or he can not cancel the work based on the business needs.