Click here to Skip to main content
15,890,973 members
Home / Discussions / C#
   

C#

 
AnswerRe: Data type mismatch in update query Pin
Luc Pattyn23-Jul-19 7:44
sitebuilderLuc Pattyn23-Jul-19 7:44 
QuestionThis is a style question regarding partial classes Pin
honey the codewitch20-Jul-19 10:40
mvahoney the codewitch20-Jul-19 10:40 
AnswerRe: This is a style question regarding partial classes Pin
BillWoodruff20-Jul-19 11:04
professionalBillWoodruff20-Jul-19 11:04 
GeneralRe: This is a style question regarding partial classes Pin
honey the codewitch20-Jul-19 11:07
mvahoney the codewitch20-Jul-19 11:07 
GeneralRe: This is a style question regarding partial classes Pin
BillWoodruff20-Jul-19 17:53
professionalBillWoodruff20-Jul-19 17:53 
GeneralRe: This is a style question regarding partial classes Pin
honey the codewitch20-Jul-19 18:10
mvahoney the codewitch20-Jul-19 18:10 
GeneralRe: This is a style question regarding partial classes Pin
#realJSOP21-Jul-19 3:35
mve#realJSOP21-Jul-19 3:35 
AnswerRe: This is a style question regarding partial classes Pin
Bernhard Hiller21-Jul-19 20:54
Bernhard Hiller21-Jul-19 20:54 
GeneralRe: This is a style question regarding partial classes Pin
honey the codewitch21-Jul-19 21:05
mvahoney the codewitch21-Jul-19 21:05 
GeneralRe: This is a style question regarding partial classes Pin
Bernhard Hiller21-Jul-19 21:35
Bernhard Hiller21-Jul-19 21:35 
GeneralRe: This is a style question regarding partial classes Pin
honey the codewitch21-Jul-19 21:40
mvahoney the codewitch21-Jul-19 21:40 
Questionhow to read data type in excel Pin
rs1919-Jul-19 6:54
rs1919-Jul-19 6:54 
AnswerRe: C# Pin
Dave Kreskowiak19-Jul-19 8:14
mveDave Kreskowiak19-Jul-19 8:14 
GeneralRe: C# Pin
rs1919-Jul-19 9:38
rs1919-Jul-19 9:38 
GeneralRe: C# Pin
Dave Kreskowiak19-Jul-19 9:49
mveDave Kreskowiak19-Jul-19 9:49 
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 

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.