Click here to Skip to main content
14,271,874 members
   

C#

 
GeneralRe: C# Pin
BillWoodruff20-Jul-19 6:41
mveBillWoodruff20-Jul-19 6:41 
GeneralRe: C# Pin
Dave Kreskowiak20-Jul-19 13:30
mveDave Kreskowiak20-Jul-19 13:30 
GeneralRe: C# Pin
BillWoodruff20-Jul-19 17:59
mveBillWoodruff20-Jul-19 17:59 
AnswerRe: C# Pin
ZurdoDev19-Jul-19 10:12
professionalZurdoDev19-Jul-19 10:12 
AnswerRe: how to read data type in excel Pin
Richard MacCutchan19-Jul-19 21:39
protectorRichard MacCutchan19-Jul-19 21:39 
AnswerRe: how to read data type in excel Pin
BillWoodruff20-Jul-19 6:44
mveBillWoodruff20-Jul-19 6:44 
QuestionWCF UnobservedTaskException Pin
Bernhard Hiller19-Jul-19 2:57
memberBernhard Hiller19-Jul-19 2:57 
AnswerRe: WCF UnobservedTaskException Pin
Richard Deeming19-Jul-19 3:40
mveRichard Deeming19-Jul-19 3:40 
Bernhard Hiller wrote:
Task task = new Task(() => RemoteChannelProvider.Call(_channel => _channel.SetInfraredFocus(_clientName, _focus)));
That line looks suspicious to me.

The RemoteChannelProvider doesn't seem to be a built-in class. What's the signature of the Call method?

What I suspect is happening is this:
  1. SetInfraredFocus returns a Task;
  2. Call may or may not discard that task;
  3. Even if it doesn't discard the task, the new Task constructor definitely discards it - none of the overloads accept a Func<Task>;
  4. The task returned from the client therefore doesn't observe the result of the task returned from the server. It could even complete before the server call has finished.


If the RemoteChannelProvider.Call method returns the Task, then you should be able to fix this by replacing the client code with:
public Task SetInfraredFocus(string _clientName, double _focus)
{
    return Task.Run(() => RemoteChannelProvider.Call(_channel => _channel.SetInfraredFocus(_clientName, _focus)));
}
Task.Run has overloads which accept a Func<Task>. The task returned from these will not complete until the inner task has completed, and it will propagate any exceptions correctly.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: WCF UnobservedTaskException Pin
Bernhard Hiller19-Jul-19 4:24
memberBernhard Hiller19-Jul-19 4:24 
GeneralRe: WCF UnobservedTaskException Pin
Richard Deeming19-Jul-19 4:41
mveRichard Deeming19-Jul-19 4:41 
GeneralRe: WCF UnobservedTaskException Pin
Bernhard Hiller21-Jul-19 21:00
memberBernhard Hiller21-Jul-19 21:00 
Question'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
BillWoodruff18-Jul-19 4:15
mveBillWoodruff18-Jul-19 4:15 
SuggestionRe: 'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
Richard Deeming18-Jul-19 5:02
mveRichard Deeming18-Jul-19 5:02 
GeneralRe: 'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
BillWoodruff18-Jul-19 5:59
mveBillWoodruff18-Jul-19 5:59 
GeneralRe: 'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
honey the codewitch20-Jul-19 10:47
memberhoney the codewitch20-Jul-19 10:47 
GeneralRe: 'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
BillWoodruff20-Jul-19 13:34
mveBillWoodruff20-Jul-19 13:34 
GeneralRe: 'Switch on 'Type: C# 7,8 offer no relief; and, Eric Lippert is still right Pin
honey the codewitch20-Jul-19 13:38
memberhoney the codewitch20-Jul-19 13:38 
QuestionProblem deserialising JSON data [SOLVED by the brilliant Richard Deeming] Pin
Richard MacCutchan18-Jul-19 2:03
protectorRichard MacCutchan18-Jul-19 2:03 
AnswerRe: Problem deserialising JSON data Pin
OriginalGriff18-Jul-19 2:35
protectorOriginalGriff18-Jul-19 2:35 
GeneralRe: Problem deserialising JSON data Pin
Richard MacCutchan18-Jul-19 3:06
protectorRichard MacCutchan18-Jul-19 3:06 
GeneralRe: Problem deserialising JSON data Pin
Richard MacCutchan18-Jul-19 4:05
protectorRichard MacCutchan18-Jul-19 4:05 
AnswerRe: Problem deserialising JSON data Pin
Richard Deeming18-Jul-19 4:42
mveRichard Deeming18-Jul-19 4:42 
GeneralRe: Problem deserialising JSON data Pin
Richard MacCutchan18-Jul-19 6:02
protectorRichard MacCutchan18-Jul-19 6:02 
QuestionGetting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Member 1453381917-Jul-19 11:29
memberMember 1453381917-Jul-19 11:29 
AnswerRe: Getting Exception Window Class Name is not Valid in Windows Application using vb.net Pin
Luc Pattyn17-Jul-19 11:49
professionalLuc Pattyn17-Jul-19 11:49 

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.