Answered Task.Completed event

  • Saturday, December 22, 2007 6:03 AM
     
     

     

    I think Completed event handler should run on main thread (from where task was created in a same way as BackgroundWorker) not in a tasks thread and specially not in separate task.

     

    Why did you implement it this way? And any luck on changing it?

All Replies

  • Monday, December 24, 2007 3:20 AM
     
     Answered

    Hi Kiforl,

     

    We are strongly considering better integration with SynchronizationContext, much like BackgroundWorker as you noted.  It turns out the Completed event model will change substantially in the future; the current scheme isn't flexible enough, and it always completes as a newly queued Task.  The absence of STA threads in the CTP is really just an indication of how early we are in the Parallel Extensions development process -- some of the super-convenient & important areas of integration like this just haven't been fully worked out yet.  But having feedback like yours is great, and will help ensure we do the right thing in the end.

     

    Take care,

    ---joe

  • Monday, December 24, 2007 3:49 AM
     
     

    Hi Joe,

     

    It's good to see Priorities in a future too. It can be done on TaskManager level (just set priority to the threads) and\or on Task level (prioritize task queue).

     

  • Monday, March 17, 2008 6:12 PM
     
     
    Joe,
       It would also be useful to add some additional events to the Task class... Namely, TaskException and TaskCancelled events. While it's possible to use the Completed event then check the IsCancelled and Exception properties it seems like a lot of overhead for developers. I can also see some confusion from some devs wondering if a Task is cancelled will the IsCompleted and IsCancelled properties both be true or just IsCancelled. I also think the issue of exception handling is fairly important (expecially for cases when a Task just performs some background operation, if I start a create a Task that doesn't return a result I have no way of being notified that the task threw an exception).


    -b