Add argument to UITask Run event?

I’m now in a strange new world modifying my older Thread / Timer code to use the UITask class to enable multiple asynchronous operations in my projects.

I’m trying to build one class instance that can handle all of the backend operations without needing to create a separate task instance for all possibilities. Aside from the command line to be executed, the rest of the logic is consistent. Because of that, I would like to pass a set of arguments to the Run event of the Task class. Should I be using the Constructor and add the arguments to that code, or is there a way to pass arguments to the Run even itself?

Anyone have input on this?

I’m not sure I understand your question. The Task class is included in the example projects so you can modify it however you want.

Of course, it might make more sense to subclass Task to add what you want and then use this subclass on your Window in place of Task.

Thanks, but my question is more of a how and where, not a “mother, may I?”. I am using a subclass, just curious as to how one would call the taskMontorJob.Run and pass arguments sine you can’t add arguments to the Run event (that I’m aware of).

Why not use properties ?

In your subclass, define a Run method that takes parameters. Store those values in properties of the subclass and call the normal Run method.

We use a Dictionary and pass that back into the main thread. That way you can put whatever you want in it.

I took Michel’s property idea and Bob’s dictionary idea and added the args as Dictionary property to the subclass. Works well and saves the creation of yet another global property :).