none
Contination not trigered

    Question

  • Hi,

    I've a problem with a continuation never called :

    if i write 

    Task.Factory.StartNew(() =>
        {
            this.importedBatchClasses = this.LoadImportedBatchClass();
        })
        .ContinueWith(
                this.HandleFailedTask,
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnFaulted,
                uiSynchronisation)
        .ContinueWith(
            previous => this.RefreshDisplayedProperties(index),
            CancellationToken.None,
            TaskContinuationOptions.None,
            uiSynchronisation)
        .ContinueWith(previous => this.RefreshCompletedEvent.Set())
    

    The RefreshCompletedEvent.Set is never called

    But if i write it like this:

    Task.Factory.StartNew(() =>
        {
            this.importedBatchClasses = this.LoadImportedBatchClass();
        })
        .ContinueWith(
                this.HandleFailedTask,
                CancellationToken.None,
                TaskContinuationOptions.OnlyOnFaulted,
                uiSynchronisation)
        .ContinueWith(previous => this.RefreshCompletedEvent.Set())
        .ContinueWith(
            previous => this.RefreshDisplayedProperties(index),
            CancellationToken.None,
            TaskContinuationOptions.None,
            uiSynchronisation)
    

    The RefreshCompletedEvent.Set is called.

    What's the difference between the twos ?

    I need the event to be setted in last 

    Thanks for any help

    Friday, January 18, 2013 9:51 PM

Answers

  • Your first code works for me: the last continuation is called. Could you include short, but complete example code that shows your issue?
    • Marked as answer by Minskaya Tuesday, January 22, 2013 4:29 PM
    Saturday, January 19, 2013 1:33 PM

All replies

  • Your first code works for me: the last continuation is called. Could you include short, but complete example code that shows your issue?
    • Marked as answer by Minskaya Tuesday, January 22, 2013 4:29 PM
    Saturday, January 19, 2013 1:33 PM
  • Thanks for your help.

    The issue occurs when the function is called from an unit test. I think the task is scheduled on the UT's thread which is blocked waiting the event.

    So I've change my mind,  and made an another way to not use an event.

    Tuesday, January 22, 2013 4:21 PM