Click here to Skip to main content
15,881,709 members
Home / Discussions / C#
   

C#

 
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 
I do not understand why there is an UnobservedTaskException in that code at all...
A method in a WCF service is defined as
[OperationContract]
[FaultContract(typeof(RemoteException))]
Task SetInfraredFocus(string _clientName, double _focus);
A WPF application calls out to it via:
public void SetFocus(double _focus)
{
    try
    {
        m_RemoteManualPsControl.SetInfraredFocus(UtilsEnvironment.TerminalName, _focus).Wait();
    }
    catch (Exception ex)
    {
        Logger.LogException(Name, ex);
    }
}
Note the .Wait() and the catch. That in turn calls the WCF client class
public Task SetInfraredFocus(string _clientName, double _focus)
{
    Task task = new Task(() => RemoteChannelProvider.Call(_channel => _channel.SetInfraredFocus(_clientName, _focus)));
    task.Start();
    return task;
}
True, I ought to add a CallAsync function to our WCF client base class, but that's quite convoluted code there...

The server (a singleton service, multi-threaded) has a simple implementation for the sake of demonstration:
public async Task SetInfraredFocus(string _clientName, double _focus)
{
    try
    {
        await Task.Delay(1);
        throw new Exception("Oh f***!");
    }
    catch (Exception ex)
    {
        Logger.LogException(Name, ex);
        RemoteException.ThrowFaultExceptionFromException(ex);
    }
}


And then I get that UnobservedTaskException... Its detail clearly shows where it comes from: it is the RemoteException created from the "Oh f***!" exception of the server. But why does the "catch" in the function on the top not catch the exception?
Oh sanctissimi Wilhelmus, Theodorus, et Fredericus!

AnswerRe: WCF UnobservedTaskException Pin
Richard Deeming19-Jul-19 3:40
mveRichard Deeming19-Jul-19 3:40 
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 

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.