Click here to Skip to main content
15,883,809 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Pin
BillWoodruff20-Jul-19 6:41
professionalBillWoodruff20-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
professionalBillWoodruff20-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
mveRichard MacCutchan19-Jul-19 21:39 
AnswerRe: how to read data type in excel Pin
BillWoodruff20-Jul-19 6:44
professionalBillWoodruff20-Jul-19 6:44 
QuestionWCF UnobservedTaskException Pin
Bernhard Hiller19-Jul-19 2:57
Bernhard Hiller19-Jul-19 2:57 
AnswerRe: WCF UnobservedTaskException Pin
Richard Deeming19-Jul-19 3:40
mveRichard Deeming19-Jul-19 3:40 
Bernhard Hiller wrote:
C#
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:
C#
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
Bernhard 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
Bernhard 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
professionalBillWoodruff18-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
professionalBillWoodruff18-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
mvahoney 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
professionalBillWoodruff20-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
mvahoney the codewitch20-Jul-19 13:38 
QuestionProblem deserialising JSON data [SOLVED by the brilliant Richard Deeming] Pin
Richard MacCutchan18-Jul-19 2:03
mveRichard MacCutchan18-Jul-19 2:03 
AnswerRe: Problem deserialising JSON data Pin
OriginalGriff18-Jul-19 2:35
mveOriginalGriff18-Jul-19 2:35 
GeneralRe: Problem deserialising JSON data Pin
Richard MacCutchan18-Jul-19 3:06
mveRichard MacCutchan18-Jul-19 3:06 
GeneralRe: Problem deserialising JSON data Pin
Richard MacCutchan18-Jul-19 4:05
mveRichard 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
mveRichard 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
Member 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
sitebuilderLuc 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.