Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: ASMX Web Services Pin
sasolanki00730-Apr-17 17:57
sasolanki00730-Apr-17 17:57 
QuestionC# Task Faulted Problem Pin
Kevin Marois10-Apr-17 8:39
professionalKevin Marois10-Apr-17 8:39 
AnswerRe: C# Task Faulted Problem Pin
User 418025410-Apr-17 10:09
User 418025410-Apr-17 10:09 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois10-Apr-17 10:32
professionalKevin Marois10-Apr-17 10:32 
GeneralRe: C# Task Faulted Problem Pin
User 418025410-Apr-17 10:58
User 418025410-Apr-17 10:58 
AnswerRe: C# Task Faulted Problem Pin
Pete O'Hanlon10-Apr-17 20:21
mvePete O'Hanlon10-Apr-17 20:21 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois11-Apr-17 4:23
professionalKevin Marois11-Apr-17 4:23 
GeneralRe: C# Task Faulted Problem Pin
Pete O'Hanlon11-Apr-17 5:09
mvePete O'Hanlon11-Apr-17 5:09 
To answer your questions back to front - did you read the code comment in the last task continuation? This one: // If you haven't reached this point, then you don't have a current App Dispatcher..If you don't see the message immediately after, it means your App.Current.Dispatcher has gone.
Kevin Marois wrote:
What benefit does it provide?
There are a few reasons I prefer this approach. Here are some of them:

  1. I can have my tasks attached to different schedulers - some of the stuff I deal with uses very complex scheduling.
  2. I'm not mixing code. Each continuation has a single responsibility
  3. This makes it very easy for me to provide general purpose continuation handlers - for instance, I could have a single OnlyOnFaulted handler that any Task calls.
  4. This reduces the cyclomatic complexity of your code
Here's an example of the last point
C#
public static class TaskExtensions
{
  public static void OnFaulted(this Task task)
  {
    task.ContinueWith(()=>{ /* do something here */ }, TaskContinuationOptions.OnlyOnFaulted);
  }
}
Calling this becomes as simple as
C#
Task.Factory.StartNew(()=> { }).OnFaulted();
Granted, a single use of this doesn't do much but when you have multiple calls of the same type, this makes things a lot neater.
This space for rent

GeneralRe: C# Task Faulted Problem Pin
Kevin Marois11-Apr-17 5:30
professionalKevin Marois11-Apr-17 5:30 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois11-Apr-17 5:34
professionalKevin Marois11-Apr-17 5:34 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois11-Apr-17 5:49
professionalKevin Marois11-Apr-17 5:49 
GeneralRe: C# Task Faulted Problem Pin
Pete O'Hanlon11-Apr-17 7:01
mvePete O'Hanlon11-Apr-17 7:01 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois11-Apr-17 7:06
professionalKevin Marois11-Apr-17 7:06 
GeneralRe: C# Task Faulted Problem Pin
Pete O'Hanlon11-Apr-17 7:55
mvePete O'Hanlon11-Apr-17 7:55 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois12-Apr-17 6:52
professionalKevin Marois12-Apr-17 6:52 
GeneralRe: C# Task Faulted Problem Pin
Pete O'Hanlon12-Apr-17 21:45
mvePete O'Hanlon12-Apr-17 21:45 
GeneralRe: C# Task Faulted Problem Pin
Kevin Marois13-Apr-17 5:34
professionalKevin Marois13-Apr-17 5:34 
QuestionXML inputs to telnet console in c# Pin
nikhil201510-Apr-17 2:47
nikhil201510-Apr-17 2:47 
QuestionRe: XML inputs to telnet console in c# Pin
Richard MacCutchan10-Apr-17 2:53
mveRichard MacCutchan10-Apr-17 2:53 
AnswerRe: XML inputs to telnet console in c# Pin
Pete O'Hanlon10-Apr-17 2:55
mvePete O'Hanlon10-Apr-17 2:55 
Questionc# Events Redirection in Designer.cs and Visual Studio 2017 More Problems. Pin
zequion7-Apr-17 20:57
professionalzequion7-Apr-17 20:57 
AnswerRe: c# Events Redirection in Designer.cs and Visual Studio 2017 More Problems. Pin
Richard MacCutchan7-Apr-17 21:33
mveRichard MacCutchan7-Apr-17 21:33 
AnswerRe: c# Events Redirection in Designer.cs and Visual Studio 2017 More Problems. Pin
Gerry Schmitz9-Apr-17 8:56
mveGerry Schmitz9-Apr-17 8:56 
AnswerRe: c# Events Redirection in Designer.cs and Visual Studio 2017 More Problems. Pin
BillWoodruff11-Apr-17 3:51
professionalBillWoodruff11-Apr-17 3:51 
AnswerRe: c# Events Redirection in Designer.cs and Visual Studio 2017 More Problems. Pin
Pete O'Hanlon11-Apr-17 4:13
mvePete O'Hanlon11-Apr-17 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.