Closed vpenades closed 3 years ago
LMK when it's ready for review again
I've considered adding the cancellationToken to the Show / ShowDialog but there's quite a lot of methods like these, are you sure you want to add the CancellationToken to every one of these methods?
Yes... Because calling Show
or ShowDialog
causes the background worker to run, I see that as a "job", and each job could have its own CancellationToken
, so having it as an argument for Show
/ ShowDialog
seems like a good direction to go. The lifecycle of the CancellationTokenSource
linked would also match the job execution lifecycle.
My initial thinking was to add new overloads (rather than include the CancellationToken
with a default value) so that it doesn't break anyone that get the package transitively, but I'm also happy to release this as a major version.
So either:
Show()
+Show(CancellationToken cancellationToken)
Show(object argument)
+Show(object argument, CancellationToken cancellationToken)
ShowDialog()
+ShowDialog(CancellationToken cancellationToken)
ShowDialog(Window owner)
+ShowDialog(Window owner, CancellationToken cancellationToken)
ShowDialog(IntPtr owner)
+ShowDialog(IntPtr owner, CancellationToken cancellationToken)
ShowDialog(Window owner, object argument)
+ShowDialog(Window owner, object argument, CancellationToken cancellationToken)
ShowDialog(IntPtr owner, object argument)
+ShowDialog(IntPtr owner, object argument, CancellationToken cancellationToken)
or
-Show()
+Show(CancellationToken cancellationToken = default)
-Show(object argument)
+Show(object argument, CancellationToken cancellationToken = default)
-ShowDialog()
+ShowDialog(CancellationToken cancellationToken = default)
-ShowDialog(Window owner)
+ShowDialog(Window owner, CancellationToken cancellationToken = default)
-ShowDialog(IntPtr owner)
+ShowDialog(IntPtr owner, CancellationToken cancellationToken = default)
-ShowDialog(Window owner, object argument)
+ShowDialog(Window owner, object argument, CancellationToken cancellationToken = default)
-ShowDialog(IntPtr owner, object argument)
+ShowDialog(IntPtr owner, object argument, CancellationToken cancellationToken = default)
@vpenades your changes have been merged, thanks for your contribution :+1:
Also Added IServiceProvider to ProgressDialog, so we can retrieve CancellationTokenSource from 'Sender' event argument.